From 7896de892b2a85edbfc339dfdded777138195bb2 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Sat, 17 Oct 2020 09:23:05 +0200 Subject: [PATCH] Fix of the "dock" menu on OSX to start a new instance of PrusaSlicer in case a single instance is disabled. Make the "single_instance" enabled by default on OSX initially to match the platform. --- src/PrusaSlicer.cpp | 3 ++- src/libslic3r/AppConfig.cpp | 8 +++++++- src/slic3r/GUI/MainFrame.cpp | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/PrusaSlicer.cpp b/src/PrusaSlicer.cpp index be66d5c54..be432d487 100644 --- a/src/PrusaSlicer.cpp +++ b/src/PrusaSlicer.cpp @@ -577,7 +577,8 @@ int CLI::run(int argc, char **argv) // #ifdef USE_WX #if ENABLE_GCODE_VIEWER GUI::GUI_App* gui = new GUI::GUI_App(start_as_gcodeviewer ? GUI::GUI_App::EAppMode::GCodeViewer : GUI::GUI_App::EAppMode::Editor); - if (gui->get_app_mode() != GUI::GUI_App::EAppMode::GCodeViewer) { // gcode viewer is currently not performing instance check + if (gui->get_app_mode() != GUI::GUI_App::EAppMode::GCodeViewer) { + // G-code viewer is currently not performing instance check, a new G-code viewer is started every time. bool gui_single_instance_setting = gui->app_config->get("single_instance") == "1"; if (Slic3r::instance_check(argc, argv, gui_single_instance_setting)) { //TODO: do we have delete gui and other stuff? diff --git a/src/libslic3r/AppConfig.cpp b/src/libslic3r/AppConfig.cpp index 9b08c086e..acc8c27c7 100644 --- a/src/libslic3r/AppConfig.cpp +++ b/src/libslic3r/AppConfig.cpp @@ -74,7 +74,13 @@ void AppConfig::set_defaults() #endif if (get("single_instance").empty()) - set("single_instance", "0"); + set("single_instance", +#ifdef __APPLE__ + "1" +#else __APPLE__ + "0" +#endif __APPLE__ + ); if (get("remember_output_path").empty()) set("remember_output_path", "1"); diff --git a/src/slic3r/GUI/MainFrame.cpp b/src/slic3r/GUI/MainFrame.cpp index 202ead404..05db7470c 100644 --- a/src/slic3r/GUI/MainFrame.cpp +++ b/src/slic3r/GUI/MainFrame.cpp @@ -56,7 +56,9 @@ public: PrusaSlicerTaskBarIcon(wxTaskBarIconType iconType = wxTBI_DEFAULT_TYPE) : wxTaskBarIcon(iconType) {} wxMenu *CreatePopupMenu() override { wxMenu *menu = new wxMenu; - if(wxGetApp().app_config->get("single_instance") == "1") { + if(wxGetApp().app_config->get("single_instance") == "0") { + // Only allow opening a new PrusaSlicer instance on OSX if "single_instance" is disabled, + // as starting new instances would interfere with the locking mechanism of "single_instance" support. append_menu_item(menu, wxID_ANY, _L("Open new instance"), _L("Open a new PrusaSlicer instance"), [this](wxCommandEvent&) { start_new_slicer(); }, "", nullptr); }