Fixed crash on Linux on startup

This commit is contained in:
Vojtech Bubnik 2020-10-01 19:16:23 +02:00
parent 2583522e43
commit b17c829c9a

View File

@ -298,6 +298,7 @@ void Tab::create_preset_tab()
// so that the cursor jumps to the last item. // so that the cursor jumps to the last item.
m_treectrl->Bind(wxEVT_TREE_SEL_CHANGED, [this](wxTreeEvent&) { m_treectrl->Bind(wxEVT_TREE_SEL_CHANGED, [this](wxTreeEvent&) {
if (!m_disable_tree_sel_changed_event && !m_pages.empty()) { if (!m_disable_tree_sel_changed_event && !m_pages.empty()) {
#ifdef WIN32
if (m_page_switch_running) if (m_page_switch_running)
m_page_switch_planned = true; m_page_switch_planned = true;
else { else {
@ -308,6 +309,10 @@ void Tab::create_preset_tab()
} while (this->tree_sel_change_delayed()); } while (this->tree_sel_change_delayed());
m_page_switch_running = false; 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<void()> throw_if_canceled)
bool Tab::tree_sel_change_delayed() 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.
// 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,
// 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.
// we will Thaw the UI prematurely on Linux. This means destroing the no_updates object prematurely.
#ifdef __linux__ #ifdef __linux__
std::unique_ptr<wxWindowUpdateLocker> no_updates(new wxWindowUpdateLocker(this)); std::unique_ptr<wxWindowUpdateLocker> no_updates(new wxWindowUpdateLocker(this));
#else #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. * 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 //#ifdef __WXOSX__ // Use Freeze/Thaw to avoid flickering during clear/activate new page
wxWindowUpdateLocker noUpdates(this); wxWindowUpdateLocker noUpdates(this);
//#endif //#endif
#endif
#endif #endif
Page* page = nullptr; Page* page = nullptr;