fix(sim): libsims not unloading (#6005)
This commit is contained in:
+34
-17
@@ -129,6 +129,10 @@ CommandLineParseResult cliOptions(SimulatorOptions * simOptions, int * profileId
|
||||
QApplication::translate("SimulatorMain", "Data source type to use. One of:") + " (file|folder|sd)",
|
||||
QApplication::translate("SimulatorMain", "type"));
|
||||
|
||||
const QCommandLineOption optFlags(QStringList() << "flags" << "f",
|
||||
QApplication::translate("SimulatorMain", "Flags passed from Companion"),
|
||||
QApplication::translate("SimulatorMain", "flags"));
|
||||
|
||||
cliOptions.addPositionalArgument(QApplication::translate("SimulatorMain", "data-source"),
|
||||
QApplication::translate("SimulatorMain", "Radio data (.bin/.eeprom/.etx) image file to use OR data folder path (for Horus-style radios).\n"
|
||||
"NOTE: any existing EEPROM data incompatible with the selected radio type may be overwritten!"),
|
||||
@@ -138,6 +142,7 @@ CommandLineParseResult cliOptions(SimulatorOptions * simOptions, int * profileId
|
||||
cliOptions.addOption(optRadio);
|
||||
cliOptions.addOption(optSdDir);
|
||||
cliOptions.addOption(optStart);
|
||||
cliOptions.addOption(optFlags);
|
||||
|
||||
QStringList args = QCoreApplication::arguments();
|
||||
#ifdef Q_OS_WIN
|
||||
@@ -211,10 +216,10 @@ CommandLineParseResult cliOptions(SimulatorOptions * simOptions, int * profileId
|
||||
if (stTyp == "file") {
|
||||
simOptions->startupDataType = SimulatorOptions::START_WITH_FILE;
|
||||
}
|
||||
else if (stTyp == "folder") {
|
||||
else if (stTyp == "folder") {
|
||||
simOptions->startupDataType = SimulatorOptions::START_WITH_FOLDER;
|
||||
}
|
||||
else if (stTyp == "sd") {
|
||||
else if (stTyp == "sd") {
|
||||
simOptions->startupDataType = SimulatorOptions::START_WITH_SDPATH;
|
||||
}
|
||||
else {
|
||||
@@ -225,6 +230,17 @@ CommandLineParseResult cliOptions(SimulatorOptions * simOptions, int * profileId
|
||||
cliOptsFound = true;
|
||||
}
|
||||
|
||||
int flags = 0;
|
||||
|
||||
if (cliOptions.isSet(optFlags)) {
|
||||
bool chk;
|
||||
flags = cliOptions.value(optFlags).toInt(&chk);
|
||||
if (!chk)
|
||||
flags = 0;
|
||||
}
|
||||
|
||||
simOptions->flags = flags;
|
||||
|
||||
*profileId = pId;
|
||||
if (cliOptsFound)
|
||||
return CommandLineFound;
|
||||
@@ -292,19 +308,6 @@ int main(int argc, char *argv[])
|
||||
int profileId = (g.simuLastProfId() > -1 ? g.simuLastProfId() : g.id());
|
||||
SimulatorOptions simOptions = g.profile[profileId].simulatorOptions();
|
||||
|
||||
// TODO : defaults should be set in Profile::init()
|
||||
if (simOptions.firmwareId.isEmpty()) {
|
||||
simOptions.firmwareId = g.profile[profileId].fwType();
|
||||
}
|
||||
|
||||
// DO NOT use saved simulatorId as could be changed in later releases
|
||||
simOptions.simulatorId = SimulatorLoader::findSimulatorByName(Firmware::getFirmwareForId(simOptions.firmwareId)->getSimulatorId());
|
||||
|
||||
if (simOptions.dataFolder.isEmpty())
|
||||
simOptions.dataFolder = g.eepromDir();
|
||||
if (simOptions.sdPath.isEmpty())
|
||||
simOptions.sdPath = g.profile[profileId].sdPath();
|
||||
|
||||
// Handle startup options
|
||||
|
||||
// check for command-line options
|
||||
@@ -315,7 +318,21 @@ int main(int argc, char *argv[])
|
||||
if (cliResult == CommandLineExitErr)
|
||||
return finish(1);
|
||||
|
||||
// Present GUI startup options dialog if necessary
|
||||
// TODO : defaults should be set in Profile::init()
|
||||
if (simOptions.firmwareId.isEmpty()) {
|
||||
simOptions.firmwareId = g.profile[profileId].fwType();
|
||||
}
|
||||
|
||||
if (simOptions.dataFolder.isEmpty())
|
||||
simOptions.dataFolder = g.eepromDir();
|
||||
if (simOptions.sdPath.isEmpty())
|
||||
simOptions.sdPath = g.profile[profileId].sdPath();
|
||||
|
||||
// DO NOT use saved simulatorId as could be changed in later releases
|
||||
// must be set after cli parse as --profile will load old data or blank
|
||||
simOptions.simulatorId = SimulatorLoader::findSimulatorByName(Firmware::getFirmwareForId(simOptions.firmwareId)->getSimulatorId());
|
||||
|
||||
// Present GUI startup options dialog if necessary
|
||||
if (cliResult == CommandLineNone || profileId == -1 || simOptions.simulatorId.isEmpty() || (simOptions.dataFile.isEmpty() && simOptions.dataFolder.isEmpty())) {
|
||||
SimulatorStartupDialog * dlg = new SimulatorStartupDialog(&simOptions, &profileId);
|
||||
int ret = dlg->exec();
|
||||
@@ -357,7 +374,7 @@ int main(int argc, char *argv[])
|
||||
//qDebug() << "current firmware:" << getCurrentFirmware()->getId();
|
||||
|
||||
int result = 0;
|
||||
SimulatorMainWindow * mainWindow = new SimulatorMainWindow(NULL, simOptions.simulatorId, SIMULATOR_FLAGS_STANDALONE);
|
||||
SimulatorMainWindow * mainWindow = new SimulatorMainWindow(nullptr, simOptions.simulatorId, (simOptions.flags ? simOptions.flags : SIMULATOR_FLAGS_STANDALONE));
|
||||
if ((result = mainWindow->getExitStatus(&resultMsg))) {
|
||||
if (resultMsg.isEmpty())
|
||||
resultMsg = QApplication::translate("SimulatorMain", "Unknown error during Simulator startup.");
|
||||
|
||||
Reference in New Issue
Block a user