Skip to content

Docking: crash in UpdateMouseWheel just after loading new docked window layout #4310

@dfeneyrou

Description

@dfeneyrou

Version/Branch of Dear ImGui:

Version: v1.84 WIP (current top of tree hash a11f368)
Branch: docking
Back-end: independant

My Issue/Question:

I got a ImGui crash when using the mouse wheel in the first frame of a newly created window.
The stack trace is (only 0->2 matter for ImGui library):

[PALANTEER] signal 11 'Segmentation fault' received
  #0  0x7F79AFB1983C : (null)
  #1  imgui.cpp(3895) : ImGui::UpdateMouseWheel()
  #2  imgui.cpp(4185) : ImGui::NewFrame()
  #3  vwPlatform.cpp(484) : vwPlatform::redraw()
  #4  vwPlatform.cpp(404) : vwPlatform::run()
  #5  vwPlatform.cpp(279) : bsBootstrap(int, char**)
  #6  bsOsLinux.cpp(813) : main

The (obvious) following 1 line patch (the line where the crash occurs) fixes the issue:

 imgui.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/imgui.cpp b/imgui.cpp
index ebd2d104..5136c9f5 100644
--- a/imgui.cpp
+++ b/imgui.cpp
@@ -3905,7 +3905,7 @@ void ImGui::UpdateMouseWheel()
     if (wheel_y != 0.0f)
     {
         StartLockWheelingWindow(window);
-        while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.y == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))))
+        while ((window->Flags & ImGuiWindowFlags_ChildWindow) && ((window->ScrollMax.y == 0.0f) || ((window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))) && window->ParentWindow)
             window = window->ParentWindow;
         if (!(window->Flags & ImGuiWindowFlags_NoScrollWithMouse) && !(window->Flags & ImGuiWindowFlags_NoMouseInputs))
         {

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions