From 3de440fda225160f6c1bf2435d245a8947a18bdb Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 18 Feb 2019 16:13:17 +0100 Subject: [PATCH] Docking: Fixed assert in DockContextProcessDock() preventing some uses of DockNodeBuilder api. (#2357, #2109) --- imgui.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 08223e3e..8f09219b 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -10624,8 +10624,9 @@ void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req) } // FIXME-DOCK: When we are trying to dock an existing single-window node into a loose window, transfer Node ID as well + // When processing an interactive split, usually LastFrameAlive will be < g.FrameCount. But DockBuilder operations can make it ==. if (target_node) - IM_ASSERT(target_node->LastFrameAlive < g.FrameCount); + IM_ASSERT(target_node->LastFrameAlive <= g.FrameCount); if (target_node && target_window && target_node == target_window->DockNodeAsHost) IM_ASSERT(target_node->Windows.Size > 0 || target_node->IsSplitNode() || target_node->IsCentralNode); @@ -11975,7 +11976,7 @@ void ImGui::DockNodeTreeSplit(ImGuiContext* ctx, ImGuiDockNode* parent_node, ImG parent_node->VisibleWindow = NULL; float size_avail = (parent_node->Size[split_axis] - IMGUI_DOCK_SPLITTER_SIZE); - IM_ASSERT(size_avail > 0.0f); + IM_ASSERT(size_avail > 0.0f); // If you created a node manually with DockBuilderAddNode(), you need to also call DockBuilderSetNodeSize() before splitting. child_0->SizeRef = child_1->SizeRef = parent_node->Size; child_0->SizeRef[split_axis] = ImFloor(size_avail * split_ratio); child_1->SizeRef[split_axis] = ImFloor(size_avail - child_0->SizeRef[split_axis]); @@ -12476,7 +12477,6 @@ ImGuiID ImGui::DockBuilderAddNode(ImGuiID id, ImGuiDockNodeFlags flags) { DockSpace(id, ImVec2(0, 0), flags | ImGuiDockNodeFlags_KeepAliveOnly); node = DockContextFindNodeByID(ctx, id); - node->LastFrameAlive = -1; } else { @@ -12484,8 +12484,8 @@ ImGuiID ImGui::DockBuilderAddNode(ImGuiID id, ImGuiDockNodeFlags flags) node = DockContextFindNodeByID(ctx, id); if (!node) node = DockContextAddNode(ctx, id); - node->LastFrameAlive = ctx->FrameCount; } + node->LastFrameAlive = ctx->FrameCount; // Set this otherwise BeginDocked will undock during the same frame. return node->ID; }