Docking: Fixed dock node with single window accidental stealing of non-owned host viewport (leading to general havoc).

This commit is contained in:
omar 2018-09-30 19:30:39 +02:00
parent 35d1fb7b34
commit 46dff42239
2 changed files with 7 additions and 2 deletions

View File

@ -7381,6 +7381,7 @@ static void ImGui::UpdateViewports()
// Update main viewport with current platform position and size
ImGuiViewportP* main_viewport = g.Viewports[0];
IM_ASSERT(main_viewport->ID == IMGUI_VIEWPORT_DEFAULT_ID);
IM_ASSERT(main_viewport->Window == NULL);
ImVec2 main_viewport_platform_pos = ImVec2(0.0f, 0.0f);
if ((g.IO.ConfigFlags & ImGuiConfigFlags_ViewportsEnable))
main_viewport_platform_pos = g.PlatformIO.Platform_GetWindowPos(main_viewport);
@ -10524,7 +10525,11 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
{
single_window->Viewport = node->HostWindow->Viewport;
single_window->ViewportId = node->HostWindow->ViewportId;
single_window->Viewport->Window = single_window;
if (node->HostWindow->ViewportOwned)
{
single_window->Viewport->Window = single_window;
single_window->ViewportOwned = true;
}
}
DockNodeHideHostWindow(node);

View File

@ -657,7 +657,7 @@ struct ImGuiViewportP : public ImGuiViewport
float Alpha; // Window opacity (when dragging dockable windows/viewports we make them transparent)
float LastAlpha;
int PlatformMonitor;
ImGuiWindow* Window;
ImGuiWindow* Window; // Set when the viewport is owned by a window
ImDrawList* OverlayDrawList; // For convenience, a draw list we can render to that's always rendered last (we use it to draw software mouse cursor when io.MouseDrawCursor is set)
ImDrawData DrawDataP;
ImDrawDataBuilder DrawDataBuilder;