From 7acaf58c154f63d0368ff2d710ca0abc3401fbd2 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Wed, 21 Jul 2021 12:55:25 +0200 Subject: [PATCH] Fix of asserting ImGui: ImGui does not want the io flags to change in between NewFrame and EndFrame. We did that - e.g. after a key down-key up combination with no render in between, or when key down and mouse move event were processed with no render in between. An assert was added in imgui to detect this between 1.75 and 1.83, which made the issue visible. Solution: only call the new_frame function in update_key_data/update_mouse_data when imgui actually consumes the input. This forces immediate render so EndFrame will be called. --- src/slic3r/GUI/ImGuiWrapper.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/slic3r/GUI/ImGuiWrapper.cpp b/src/slic3r/GUI/ImGuiWrapper.cpp index 799b5be4ac..9980ba5a71 100644 --- a/src/slic3r/GUI/ImGuiWrapper.cpp +++ b/src/slic3r/GUI/ImGuiWrapper.cpp @@ -204,7 +204,8 @@ bool ImGuiWrapper::update_mouse_data(wxMouseEvent& evt) unsigned buttons = (evt.LeftIsDown() ? 1 : 0) | (evt.RightIsDown() ? 2 : 0) | (evt.MiddleIsDown() ? 4 : 0); m_mouse_buttons = buttons; - new_frame(); + if (want_mouse()) + new_frame(); return want_mouse(); } @@ -222,9 +223,6 @@ bool ImGuiWrapper::update_key_data(wxKeyEvent &evt) if (key != 0) { io.AddInputCharacter(key); } - - new_frame(); - return want_keyboard() || want_text_input(); } else { // Key up/down event int key = evt.GetKeyCode(); @@ -235,10 +233,11 @@ bool ImGuiWrapper::update_key_data(wxKeyEvent &evt) io.KeyCtrl = evt.ControlDown(); io.KeyAlt = evt.AltDown(); io.KeySuper = evt.MetaDown(); - - new_frame(); - return want_keyboard() || want_text_input(); } + bool ret = want_keyboard() || want_text_input(); + if (ret) + new_frame(); + return ret; } void ImGuiWrapper::new_frame()