Set sensible defaults if autosave and datadir aren't specified on the CLI instead of segfaulting when the GUI is enabled.

datadir goes to home directory, autosave is in a temp dir and has format slic3r_autosave_xxx.
This commit is contained in:
Joseph Lenox 2019-06-03 22:18:22 -05:00
parent 6bb8a750bc
commit a0a2055916

View File

@ -354,8 +354,18 @@ int CLI::run(int argc, char **argv) {
if (actions.empty()) {
#ifdef USE_WX
GUI::App *gui = new GUI::App();
gui->autosave = this->config.getString("autosave");
gui->datadir = this->config.getString("datadir");
try {
gui->autosave = this->config.getString("autosave");
} catch(Slic3r::UnknownOptionException &e) {
// if no autosave, set a sensible default.
gui->autosave = wxFileName::CreateTempFileName("slic3r_autosave_").ToStdString();
}
try {
gui->datadir = this->config.getString("datadir");
} catch(Slic3r::UnknownOptionException &e) {
// if no datadir on the CLI, set a default.
gui->datadir = GUI::home().ToStdString();
}
GUI::App::SetInstance(gui);
wxEntry(argc, argv);
#else