From 0df757895e1017f17d615927a736337cef33f9f2 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Thu, 11 Aug 2022 11:32:51 +0200 Subject: [PATCH] An attempt to fix issues with wxProgressDialog --- src/slic3r/GUI/Plater.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 20783f0fc..8961d260a 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2379,9 +2379,20 @@ std::vector Plater::priv::load_files(const std::vector& input_ const auto loading = _L("Loading") + dots; - // Create wxProgressDialog on heap, see the linux ifdef below. - auto progress_dlg = new wxProgressDialog(loading, "", 100, find_toplevel_parent(q), wxPD_AUTO_HIDE); + // The situation with wxProgressDialog is quite interesting here. + // On Linux (only), there are issues when FDM/SLA is switched during project file loading (disabling of controls, + // see a comment below). This can be bypassed by creating the wxProgressDialog on heap and destroying it + // when loading a project file. However, creating the dialog on heap causes issues on macOS, where it does not + // appear at all. Therefore, we create the dialog on stack on Win and macOS, and on heap on Linux, which + // is the only system that needed the workarounds in the first place. +#ifdef __linux__ + auto progress_dlg = new wxProgressDialog(loading, "", 100, find_toplevel_parent(q), wxPD_APP_MODAL | wxPD_AUTO_HIDE); Slic3r::ScopeGuard([&progress_dlg](){ if (progress_dlg) progress_dlg->Destroy(); progress_dlg = nullptr; }); +#else + wxProgressDialog progress_dlg_stack(loading, "", 100, find_toplevel_parent(q), wxPD_APP_MODAL | wxPD_AUTO_HIDE); + wxProgressDialog* progress_dlg = &progress_dlg_stack; +#endif + wxBusyCursor busy;