Prevent crash on setup parsing file error + activate first mode if none specified
This commit is contained in:
parent
c21f51bf46
commit
b4abca85c1
@ -1117,6 +1117,8 @@ void AppWindow::LoadSetup(QString filename)
|
||||
} catch (exception &e) {
|
||||
InformationBox::ShowError("Error", "Failed to parse the setup file (" + QString(e.what()) + ")");
|
||||
qWarning() << "Parsing of setup file failed: " << e.what();
|
||||
file.close();
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
LoadSetup(j);
|
||||
@ -1170,6 +1172,10 @@ void AppWindow::LoadSetup(nlohmann::json j)
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if no mode is activated, there might have been a problem with the setup file. Activate the first mode anyway, to prevent invalid GUI state
|
||||
if(!Mode::getActiveMode() && Mode::getModes().size() > 0) {
|
||||
Mode::getModes()[0]->activate();
|
||||
}
|
||||
}
|
||||
|
||||
Device *&AppWindow::getDevice()
|
||||
|
Loading…
Reference in New Issue
Block a user