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.
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,7 +3394,6 @@ void Tab::activate_selected_page(std::function<void()> 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.
@ -3403,7 +3407,6 @@ bool Tab::tree_sel_change_delayed()
//#ifdef __WXOSX__ // Use Freeze/Thaw to avoid flickering during clear/activate new page
wxWindowUpdateLocker noUpdates(this);
//#endif
#endif
#endif
Page* page = nullptr;