Skip to content
New issue

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

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

Already on GitHub? # to your account

TabBars in Tab can cause crash #2371

Closed
cmheo opened this issue Feb 22, 2019 · 3 comments
Closed

TabBars in Tab can cause crash #2371

cmheo opened this issue Feb 22, 2019 · 3 comments
Labels

Comments

@cmheo
Copy link

cmheo commented Feb 22, 2019

Version/Branch of Dear ImGui:

Version: 1.69 WIP (16899)
Branch: master

Back-end/Renderer/Compiler/OS

Back-ends: imgui_impl_glfw.cpp + imgui_impl_opengl2.cpp

if (show_crash_window)
{
	char buf[2048] = { 0 };

	ImGui::Begin("TabBar Crash", &show_crash_window);

	ImGuiTabBarFlags tab_bar_flags = ImGuiTabBarFlags_None;
	if (ImGui::BeginTabBar("TabBar 0", tab_bar_flags))
	{
		if (ImGui::BeginTabItem("TabItem 0 in TabBar 0"))
		{
			ImGui::Text("TabItem 0 in TabBar 0");

			// if we have many tab bars here, it will invalidate pointers in g.CurrentTabBar
			for (int i = 0; i < 128; i++)
			{
				sprintf(buf, "Inner TabBar %d", i);
				if (ImGui::BeginTabBar(buf, tab_bar_flags))
				{
					sprintf(buf, "Inner TabBar %d TabItem", i);
					if (ImGui::BeginTabItem(buf))
					{
						ImGui::Text("Inner TabBar TabItem");
						ImGui::EndTabItem();
					}

					ImGui::EndTabBar();
				}
			}

			ImGui::Text("TabBar 0 pointer in g.CurrentTabar is invalid");
			ImGui::EndTabItem();
		}

		ImGui::EndTabBar();
	}

	ImGui::End();
}
@ocornut ocornut added the bug label Feb 22, 2019
@ocornut
Copy link
Owner

ocornut commented Feb 22, 2019

Confirmed the bug, thank you. It's a really silly error on my side to have let that go (the stack stores tabbar pointers that are pointing to a resizable vector). Fixing soon.

ocornut added a commit that referenced this issue Feb 22, 2019
…fect docking). (#2371)

Added ImPool::Contains() helper.
@ocornut
Copy link
Owner

ocornut commented Feb 22, 2019

I have pushed a fix for this, confirmed with docking branch and added a test for recursive manual tab bar in my wip testing system. Thanks again!

@cmheo
Copy link
Author

cmheo commented Feb 25, 2019

Thank you! I will pull the fix. Thanks again.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants