From b17c829c9ad3302e4960f16929fdd10698c4ad79 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Thu, 1 Oct 2020 19:16:23 +0200 Subject: [PATCH] Fixed crash on Linux on startup --- src/slic3r/GUI/Tab.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index e6363b3d0..c99ddeecd 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -298,6 +298,7 @@ void Tab::create_preset_tab() // so that the cursor jumps to the last item. m_treectrl->Bind(wxEVT_TREE_SEL_CHANGED, [this](wxTreeEvent&) { if (!m_disable_tree_sel_changed_event && !m_pages.empty()) { +#ifdef WIN32 if (m_page_switch_running) m_page_switch_planned = true; else { @@ -308,6 +309,10 @@ void Tab::create_preset_tab() } while (this->tree_sel_change_delayed()); m_page_switch_running = false; } +#else + // Crashes on Linux on start-up without CallAfter. + this->CallAfter([this]() { this->tree_sel_change_delayed(); }); +#endif } }); @@ -3389,10 +3394,9 @@ void Tab::activate_selected_page(std::function throw_if_canceled) bool Tab::tree_sel_change_delayed() { -#if 1 - // There is a bug related to Ubuntu overlay scrollbars, see https://github.com/prusa3d/PrusaSlicer/issues/898 and https://github.com/prusa3d/PrusaSlicer/issues/952. - // The issue apparently manifests when Show()ing a window with overlay scrollbars while the UI is frozen. For this reason, - // we will Thaw the UI prematurely on Linux. This means destroing the no_updates object prematurely. + // There is a bug related to Ubuntu overlay scrollbars, see https://github.com/prusa3d/PrusaSlicer/issues/898 and https://github.com/prusa3d/PrusaSlicer/issues/952. + // The issue apparently manifests when Show()ing a window with overlay scrollbars while the UI is frozen. For this reason, + // we will Thaw the UI prematurely on Linux. This means destroing the no_updates object prematurely. #ifdef __linux__ std::unique_ptr no_updates(new wxWindowUpdateLocker(this)); #else @@ -3401,9 +3405,8 @@ bool Tab::tree_sel_change_delayed() * But under OSX (builds compiled with MacOSX10.14.sdk) wxStaticBitmap rendering is broken without Freeze/Thaw call. */ //#ifdef __WXOSX__ // Use Freeze/Thaw to avoid flickering during clear/activate new page - wxWindowUpdateLocker noUpdates(this); + wxWindowUpdateLocker noUpdates(this); //#endif -#endif #endif Page* page = nullptr;