[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:
@@ -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);
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user