ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
61.35k stars 10.33k forks source link

More than one BeginTabItem()s crashes program #7456

Closed Sensuikan-U511 closed 8 months ago

Sensuikan-U511 commented 8 months ago

Version/Branch of Dear ImGui:

Version 1.90, master

Back-ends:

imgui_impl_opengl3.cpp

Compiler, OS:

Windows 11, Visual Studio 2022

Full config/build information:

No response

Details:

My Issue:

If I use one BeginTabItem(), it works. If I use two BeginTabItem(), it crashes. Two different failure modes possible.

If I use an EndTabItem() before the second BeginTabItem(), the program fails on execution with error: "Assertion failed: window->IDStack.Size > 1, file [path to imgui.cpp], line 8021".

If I don't use an EndTabItem(), then both buttons will show up in the first tab even with the second button under the second BeginTabItem(). Both tabs will also show up, but clicking the second tab will crash the program, with the same error as above.

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

// Here's some code anyone can copy and paste to reproduce your issue
ImGui::Begin("Example Bug");
ImGui::BeginTabBar("1");
ImGui::BeginTabItem("Cats");
if (ImGui::Button("Meow"))
    //render.text[0].setString("meow"); //object manip test has no impact on the bug
ImGui::EndTabItem();
ImGui::BeginTabItem("Dogs");
if (ImGui::Button("Woof"))
    //render.text[0].setString("woof");
ImGui::EndTabItem();
ImGui::EndTabBar();
ImGui::End();
Sensuikan-U511 commented 8 months ago

My syntax was wrong. I did not realise I needed to wrap the tab bars and buttons in if statements. Problem solved, sorry for the bother (but I do wish there was documentation other than digging through the demo .cpp!).