Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docking a Window manually causes an assert indised of DockNodeFindInfo #8145

Open
Link459 opened this issue Nov 10, 2024 · 2 comments
Open
Labels

Comments

@Link459
Copy link

Link459 commented Nov 10, 2024

Version/Branch of Dear ImGui:

Version: 1.91.5
Branch: docking

Back-ends:

imgui_impl_vulkan.cpp + imgui_impl_sdl3.cpp

Compiler, OS:

linux + gcc 14.2.1

Full config/build information:

[Window][Debug##Default]
Pos=60,60
Size=400,400
Collapsed=0

[Window][Hello, world!]
Pos=283,408
Size=339,180
Collapsed=0

[Window][Dear ImGui Demo]
Pos=899,214
Size=550,680
Collapsed=0

[Window][WindowOverViewport_11111111]
Pos=0,0
Size=1916,1076
Collapsed=0

[Window][Viewport]
Pos=0,0
Size=1916,1076
Collapsed=0
DockId=0x03954D96,0

[Window][Another Window]
Pos=60,60
Size=198,71
Collapsed=0

[Docking][Data]
DockSpace ID=0x03954D96 Window=0xA87D555D Pos=0,0 Size=1916,1076 CentralNode=1 Selected=0x13926F0B

Details:

Docking window results in an assert inside DockNodeFindInfo

I was trying to programmatically attach a window to a dock space on the central node.
It was attaching the window correctly as far as I can tell but once I tried to manually attach another window to the dockspace I got this assert:

void DockNodeFindInfo(ImGuiDockNode*, ImGuiDockNodeTreeInfo*): Assertion `node->IsLeafNode() && "If you get this assert: please submit .ini file + repro of actions leading to this."' failed.

This happened whenever I tried to attach a window to the left, right, bottom or top of the dockspace.

Screenshots/Video:

imgui_docking.mp4

Minimal, Complete and Verifiable Example code:

ImGuiID id = ImGui::GetID("dock_space");
ImGuiViewport* viewport = ImGui::GetMainViewport();
ImGuiID dockspace = ImGui::DockSpaceOverViewport(id, viewport,ImGuiDockNodeFlags_PassthruCentralNode | ImGuiDockNodeFlags_CentralNode);
if (ImGui::Begin("Viewport", nullptr,
    ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoNavInputs | ImGuiWindowFlags_NoTitleBar))
{
    ImGui::End(); 
}
ImGuiID dockspace_id = ImGui::GetID("dock_space");
ImGui::DockBuilderDockWindow("Viewport", dockspace_id);
ImGui::DockBuilderFinish(dockspace_id);
@ocornut
Copy link
Owner

ocornut commented Nov 12, 2024

(
For the record, your code is a bit confusing because you are holding the same value in three spots:

ImGuiID id = ImGui::GetID("dock_space");
[...]
ImGuiID dockspace = ImGui::DockSpaceOverViewport(id, ....); // this return the value you passed to it (if you pass 0 it generates an id)
[...]
ImGuiID dockspace_id = ImGui::GetID("dock_space");

Therefore in your code id and dockspace and dockspace_id are all the same value!
)

I will investigate the main issue later.

@ocornut
Copy link
Owner

ocornut commented Nov 26, 2024

I was a little confused by this, and then realized the (non-obvious) issue:

Passing ImGuiDockNodeFlags_CentralNode to DockSpace() or DockSpaceOverViewport() is not only unnecessary (because DockSpace currently adds it) but it creates a huge bug as the flag is stored in node->SharedFlags and then not moved to inheriting child when split, creating a largely inconsistent state.

If you remove the ImGuiDockNodeFlags_CentralNode value it should work.
Note that in your repro you are calling DockBuilderDockWindow() every frame which is likely not desirable. You may want to check earlier if the node existed, or if you are in a special reset state, in order to call.

I am going to research if I can better document/fix this, possibly by making it clearly illegal to pass this flag to DockSpace(), but it's part of a larger required rework as the concept of CentralNode is quite confusing/broken right now.

ocornut added a commit that referenced this issue Nov 26, 2024
…de flag does not need to be passed to DockSpace(). (#8145)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants