Skip to content

Commit

Permalink
Error Handling: fixed not rewinding to recorded tree and id stack size (
Browse files Browse the repository at this point in the history
  • Loading branch information
ocornut committed Sep 27, 2024
1 parent 30c29d2 commit 199a44e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10465,6 +10465,7 @@ void ImGui::ErrorRecoveryStoreState(ImGuiErrorRecoveryState* state_out)
ImGuiContext& g = *GImGui;
state_out->SizeOfWindowStack = (short)g.CurrentWindowStack.Size;
state_out->SizeOfIDStack = (short)g.CurrentWindow->IDStack.Size;
state_out->SizeOfTreeStack = (short)g.CurrentWindow->DC.TreeDepth; // NOT g.TreeNodeStack.Size which is a partial stack!
state_out->SizeOfColorStack = (short)g.ColorStack.Size;
state_out->SizeOfStyleVarStack = (short)g.StyleVarStack.Size;
state_out->SizeOfFontStack = (short)g.FontStack.Size;
Expand Down Expand Up @@ -10531,7 +10532,7 @@ void ImGui::ErrorRecoveryTryToRecoverWindowState(const ImGuiErrorRecoveryStat
IM_ASSERT_USER_ERROR(0, "Missing EndMultiSelect()");
EndMultiSelect();
}
while (window->DC.TreeDepth > 0)
while (window->DC.TreeDepth > state_in->SizeOfTreeStack) //-V1044
{
IM_ASSERT_USER_ERROR(0, "Missing TreePop()");
TreePop();
Expand All @@ -10542,7 +10543,7 @@ void ImGui::ErrorRecoveryTryToRecoverWindowState(const ImGuiErrorRecoveryStat
EndGroup();
}
IM_ASSERT(g.GroupStack.Size == state_in->SizeOfGroupStack);
while (window->IDStack.Size > 1)
while (window->IDStack.Size > state_in->SizeOfIDStack) //-V1044
{
IM_ASSERT_USER_ERROR(0, "Missing PopID()");
PopID();
Expand Down
1 change: 1 addition & 0 deletions imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1258,6 +1258,7 @@ struct IMGUI_API ImGuiErrorRecoveryState
{
short SizeOfWindowStack;
short SizeOfIDStack;
short SizeOfTreeStack;
short SizeOfColorStack;
short SizeOfStyleVarStack;
short SizeOfFontStack;
Expand Down

0 comments on commit 199a44e

Please sign in to comment.