From c19dea84724f52ba3db97eb311c7e92770158ede Mon Sep 17 00:00:00 2001 From: Andre Bernet Date: Thu, 10 Apr 2014 10:24:11 +0200 Subject: [PATCH] Standalone simu would crash for "normal" Windows users on launch as they don't have write permissions to the Program Files folder. New method should be portable and store eeprom files in the user's standard document location. --- companion/src/simulator.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/companion/src/simulator.cpp b/companion/src/simulator.cpp index 3f9a2362f..1d61c698a 100644 --- a/companion/src/simulator.cpp +++ b/companion/src/simulator.cpp @@ -102,6 +102,10 @@ int main(int argc, char *argv[]) RegisterFirmwares(); SimulatorDialog *dialog; const char * eepromFileName; + QString fileName; + QByteArray path; + QDir eedir; + QFile file; QMessageBox msgBox; msgBox.setWindowTitle("Radio type"); @@ -111,17 +115,27 @@ int main(int argc, char *argv[]) msgBox.addButton("9X", QMessageBox::ActionRole); QPushButton *exitButton = msgBox.addButton(QMessageBox::Close); + eedir = QDir(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)); + if (!eedir.exists("OpenTX")) { + eedir.mkdir("OpenTX"); + } + eedir.cd("OpenTX"); + msgBox.exec(); if (msgBox.clickedButton() == exitButton) return 0; else if (msgBox.clickedButton() == taranisButton) { current_firmware_variant = GetFirmwareVariant("opentx-taranis-en"); - eepromFileName = "eeprom-taranis.bin"; + fileName = eedir.filePath("eeprom-taranis.bin"); + path = fileName.toAscii(); + eepromFileName = path.data(); dialog = new SimulatorDialogTaranis(); } else { - eepromFileName = "eeprom-9x.bin"; + fileName = eedir.filePath("eeprom-9x.bin"); + path = fileName.toAscii(); + eepromFileName = path.data(); dialog = new SimulatorDialog9X(); }