diff --git a/imgui.cpp b/imgui.cpp index df2575b15e9e..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 < DC.Layouts.Data.Size; i++) - { - ImGuiLayout* layout = (ImGuiLayout*)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