[Simulator] Make sure a default Data File is always suggested in startup dialog; Fix silent exit upon startup if no file/data was provided.

This commit is contained in:
Max Paperno
2017-02-01 04:04:51 -05:00
parent fe76ecfe02
commit 9c6a543434
3 changed files with 13 additions and 4 deletions
+6 -1
View File
@@ -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 // 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; startupData = dataSource;
startupFromFile = true; startupFromFile = true;
return true; return true;
} }
else { else {
ret = 0;
error = store.error(); 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()) { else if (options.startupDataType == SimulatorOptions::START_WITH_FILE && !options.dataFile.isEmpty()) {
ret = setStartupData(options.dataFile.toLocal8Bit(), true); 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) if (ret && withSave)
g.profile[radioProfileId].simulatorOptions(options); g.profile[radioProfileId].simulatorOptions(options);
@@ -173,8 +173,9 @@ void SimulatorStartupDialog::loadRadioProfile(int id)
ui->radioType->setCurrentIndex(i); ui->radioType->setCurrentIndex(i);
tmpstr = m_options->dataFile; tmpstr = m_options->dataFile;
if (!tmpstr.isEmpty()) if (tmpstr.isEmpty())
ui->dataFile->setText(tmpstr); tmpstr = radioEepromFileName(ui->radioType->currentText());
ui->dataFile->setText(tmpstr);
tmpstr = m_options->dataFolder; tmpstr = m_options->dataFolder;
if (tmpstr.isEmpty()) if (tmpstr.isEmpty())
+4 -1
View File
@@ -276,11 +276,14 @@ int main(int argc, char *argv[])
int result = 1; int result = 1;
SimulatorDialog * dialog = new SimulatorDialog(NULL, simulator, SIMULATOR_FLAGS_STANDALONE); SimulatorDialog * dialog = new SimulatorDialog(NULL, simulator, SIMULATOR_FLAGS_STANDALONE);
dialog->setRadioProfileId(profileId); dialog->setRadioProfileId(profileId);
if ((result = (int)dialog->setOptions(simOptions, true))) { if (dialog->setOptions(simOptions, true)) {
dialog->start(); dialog->start();
dialog->show(); dialog->show();
result = app.exec(); result = app.exec();
} }
else {
result = 3;
}
g.id(oldProfId); g.id(oldProfId);
delete dialog; delete dialog;
delete simulator; delete simulator;