From a0a205591678f2296b6846f670fb450019b6610a Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Mon, 3 Jun 2019 22:18:22 -0500 Subject: [PATCH] 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. --- src/slic3r.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/slic3r.cpp b/src/slic3r.cpp index 25d86c272..8b30c2f09 100644 --- a/src/slic3r.cpp +++ b/src/slic3r.cpp @@ -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