From 1d584c0ae2943bedd23072e50e8028825396ef40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Iv=C3=A1n=20Chaparro=20Barese?= Date: Thu, 14 Sep 2023 05:44:09 +0200 Subject: [PATCH 1/2] Fixed 'DC': undeclared identifier error --- imgui.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index df2575b15e9e..89ef246e4652 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3836,9 +3836,9 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window) ImGuiContext& g = *GImGui; - for (int i = 0; i < DC.Layouts.Data.Size; i++) + for (int i = 0; i < window->DC.Layouts.Data.Size; i++) { - ImGuiLayout* layout = (ImGuiLayout*)DC.Layouts.Data[i].val_p; + ImGuiLayout* layout = (ImGuiLayout*)window->DC.Layouts.Data[i].val_p; IM_DELETE(layout); } // While most behaved code would make an effort to not steal active id during window move/drag operations, From 45eb48eaa435aba505fa5c1e5470672e448c91ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gonzalo=20Iv=C3=A1n=20Chaparro=20Barese?= Date: Thu, 14 Sep 2023 07:09:37 +0200 Subject: [PATCH 2/2] Wrapped changes in an if statement In order to check if the window is not a null pointer. This made the application crash --- imgui.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 89ef246e4652..f38c5008ba78 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3835,11 +3835,12 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window) { ImGuiContext& g = *GImGui; - - for (int i = 0; i < window->DC.Layouts.Data.Size; i++) - { - ImGuiLayout* layout = (ImGuiLayout*)window->DC.Layouts.Data[i].val_p; - IM_DELETE(layout); + if (window != nullptr) { + for (int i = 0; i < window->DC.Layouts.Data.Size; i++) + { + ImGuiLayout* layout = (ImGuiLayout*)window->DC.Layouts.Data[i].val_p; + IM_DELETE(layout); + } } // While most behaved code would make an effort to not steal active id during window move/drag operations, // we at least need to be resilient to it. Cancelling the move is rather aggressive and users of 'master' branch