1
0
Fork 0
mirror of https://github.com/EdgeTX/edgetx.git synced 2025-07-23 16:25:12 +03:00

[Simulator] Fix startup when using a new file for radio data (file is now properly created, errors from Storage are ignored); Do not start simulator at all in case of data errors; Fix startup option dialog when finding radio type from profile for first time; Fix RadioOptions struct version control; Cleanup unused WinConsole code; Fix a warning and a missing const reference; Move ~SimulatedUIWidget() to public.

This commit is contained in:
Max Paperno 2017-01-28 18:50:26 -05:00
parent 32dc0dd2a0
commit fae095ea18
9 changed files with 54 additions and 52 deletions

View file

@ -815,17 +815,6 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
{
SimulatorInterface * simulator = getCurrentSimulator();
if (simulator) {
#if defined(WIN32) && defined(WIN_USE_CONSOLE_STDIO)
bool freeConsoleOnClose = false;
if (!GetConsoleWindow()) {
AllocConsole();
SetConsoleTitle("Companion Console");
freeConsoleOnClose = true;
freopen("conin$", "r", stdin);
freopen("conout$", "w", stdout);
freopen("conout$", "w", stderr);
}
#endif
RadioData * simuData = new RadioData(radioData);
unsigned int flags = 0;
@ -837,19 +826,17 @@ void startSimulation(QWidget * parent, RadioData & radioData, int modelIdx)
SimulatorDialog * dialog = new SimulatorDialog(parent, simulator, flags);
if (IS_HORUS(getCurrentBoard()) && !dialog->useTempDataPath(true)) {
QMessageBox::critical(NULL, QObject::tr("Data Load Error"), QObject::tr("Error: Could not create temporary directory in '%1'").arg(QDir::tempPath()));
delete dialog;
delete simuData;
return;
}
dialog->setRadioData(simuData);
qDebug() << __FILE__ << __LINE__ << "Starting" << getCurrentFirmware()->getName() << "simulation with SD path" << dialog->getSdPath() << "and models/settings path" << dialog->getDataPath();
dialog->start();
dialog->exec();
dialog->deleteLater();
delete dialog;
// TODO Horus tmp directory is deleted on simulator close OR we could use it to get back data from the simulation
delete simuData; // TODO same with simuData, could read it back and update the file data
#if defined(WIN32) && defined(WIN_USE_CONSOLE_STDIO)
if (freeConsoleOnClose)
FreeConsole();
#endif
}
else {
QMessageBox::warning(NULL,