diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 86394819e..96151d8c7 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3481,6 +3481,28 @@ void Tab::activate_selected_page(std::function throw_if_canceled) toggle_options(); } +#ifdef WIN32 +// Override the wxCheckForInterrupt to process inperruptions just from key or mouse +// and to avoid an unwanted early call of CallAfter() +static bool CheckForInterrupt(wxWindow* wnd) +{ + wxCHECK(wnd, false); + + MSG msg; + while (::PeekMessage(&msg, ((HWND)((wnd)->GetHWND())), WM_KEYFIRST, WM_KEYLAST, PM_REMOVE)) + { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + while (::PeekMessage(&msg, ((HWND)((wnd)->GetHWND())), WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE)) + { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + } + return true; +} +#endif //WIN32 + bool Tab::tree_sel_change_delayed() { // 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. @@ -3517,7 +3539,7 @@ bool Tab::tree_sel_change_delayed() auto throw_if_canceled = std::function([this](){ #ifdef WIN32 - wxCheckForInterrupt(m_treectrl); + CheckForInterrupt(m_treectrl); if (m_page_switch_planned) throw UIBuildCanceled(); #else // WIN32