Docking: Fix dock split of current window before End() assertion trigger#9475
Open
SuperRonan wants to merge 1 commit into
Open
Docking: Fix dock split of current window before End() assertion trigger#9475SuperRonan wants to merge 1 commit into
End() assertion trigger#9475SuperRonan wants to merge 1 commit into
Conversation
- Fix erroneous reset `window->DockIsActive` to `false` of first docked window in `ImGui::DockNodeMoveWindows()`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem:
An assertion is raised when calling
ImGui::DockBuilderSplitNode()on aDockIdwhich owns a window that is currently being declared (betweenBegin()andEnd()).More precisely:
We have an
ImGuiID dock_id, and anImGuiDockNode* ncorreponding to it; we also have anImGuiWindow* wthat is currently being declared and such asn->Windows[0] = w(being the first window in the list is important).We call
ImGui::DockBuilderSplitNode(dock_id, ...), which callsImGui::DockNodeTreeSplit(ctx, n, ...), which creates two child nodes, and moves windows from the parentnto one of the children.DockNodeMoveWindows(dst, src)addssrc's windows todstone at the time usingDockNodeAddWindow(). The latter setswindow->DockIsActive = (node->Windows.Size > 1);, which is going to be false for the first window of the list to be moved (w).Latter, during
End()ofw, an assertion will fail:This assertion should not be checked because
window->DockIsActiveshould have beentrue(it would have been the case ifwwas not the first window in the listn->Window, and it is not the case for other windows docked ton).I have made a basic example to illustrate this issue. It is available in a separate commit e81ac55.
Note that this issue does not exists if docking manipulation is done outside of window declaration (such as docking manipulation done with the mouse).
Solution:
I am proposing to fix the above
w->DockIsActive == falsethat appears to be erroneous.I don't have a complete overview of the docking system, so the solution I am proposing in this PR might not be the best (Still I checked that all tests of the test engine passed).
I prefer not touching to
window->DockIsActive = (node->Windows.Size > 1);inDockNodeAddWindow().I think it makes most sense to fix it in
DockNodeMoveWindows()(this current PR). Although this issue was found with a splitting, other docking operations that move windows from one node to another may trigger the same assertion error, and the source of the problems is inDockNodeMoveWindows().Alternatively, the initial error maybe was to use the
DockBuilderon the dock of a window during its declaration. We could explicitely forbid these kind of manipulations, but I am not very fond of such restrictions.