From 9c6a5434342be1f8c0d51cf35ae599518f0fc6c8 Mon Sep 17 00:00:00 2001 From: Max Paperno Date: Wed, 1 Feb 2017 03:48:06 -0500 Subject: [PATCH] [Simulator] Make sure a default Data File is always suggested in startup dialog; Fix silent exit upon startup if no file/data was provided. --- companion/src/simulation/simulatordialog.cpp | 7 ++++++- companion/src/simulation/simulatorstartupdialog.cpp | 5 +++-- companion/src/simulator.cpp | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/companion/src/simulation/simulatordialog.cpp b/companion/src/simulation/simulatordialog.cpp index 4ba988dd6..150afb1f2 100644 --- a/companion/src/simulation/simulatordialog.cpp +++ b/companion/src/simulation/simulatordialog.cpp @@ -202,12 +202,13 @@ bool SimulatorDialog::setStartupData(const QByteArray & dataSource, bool fromFil } } // again there's no way to tell what the error from Storage actually was, so if the file doesn't exist we'll create a new one - else if (!QFile(QString(dataSource)).exists()) { + else if (!dataSource.isEmpty() && !QFile(QString(dataSource)).exists()) { startupData = dataSource; startupFromFile = true; return true; } else { + ret = 0; error = store.error(); } } @@ -265,6 +266,10 @@ bool SimulatorDialog::setOptions(SimulatorOptions & options, bool withSave) else if (options.startupDataType == SimulatorOptions::START_WITH_FILE && !options.dataFile.isEmpty()) { ret = setStartupData(options.dataFile.toLocal8Bit(), true); } + else { + QString error = tr("Invalid startup data provided. Plese specify a proper file/path."); + QMessageBox::critical(this, tr("Simulator Startup Error"), error); + } if (ret && withSave) g.profile[radioProfileId].simulatorOptions(options); diff --git a/companion/src/simulation/simulatorstartupdialog.cpp b/companion/src/simulation/simulatorstartupdialog.cpp index d1eca2e38..6fe72ba4f 100644 --- a/companion/src/simulation/simulatorstartupdialog.cpp +++ b/companion/src/simulation/simulatorstartupdialog.cpp @@ -173,8 +173,9 @@ void SimulatorStartupDialog::loadRadioProfile(int id) ui->radioType->setCurrentIndex(i); tmpstr = m_options->dataFile; - if (!tmpstr.isEmpty()) - ui->dataFile->setText(tmpstr); + if (tmpstr.isEmpty()) + tmpstr = radioEepromFileName(ui->radioType->currentText()); + ui->dataFile->setText(tmpstr); tmpstr = m_options->dataFolder; if (tmpstr.isEmpty()) diff --git a/companion/src/simulator.cpp b/companion/src/simulator.cpp index afe292aa4..af5dcad53 100644 --- a/companion/src/simulator.cpp +++ b/companion/src/simulator.cpp @@ -276,11 +276,14 @@ int main(int argc, char *argv[]) int result = 1; SimulatorDialog * dialog = new SimulatorDialog(NULL, simulator, SIMULATOR_FLAGS_STANDALONE); dialog->setRadioProfileId(profileId); - if ((result = (int)dialog->setOptions(simOptions, true))) { + if (dialog->setOptions(simOptions, true)) { dialog->start(); dialog->show(); result = app.exec(); } + else { + result = 3; + } g.id(oldProfId); delete dialog; delete simulator;