Error recovery: Extraneous/undesired calls to End() are now being caught by an assert in the End() function itself at the call site (instead of being reported in EndFrame). Past the assert, they don't lead to crashes any more. Missing calls to End(), pass the assert, should not lead to crashes any more, nor to the fallback/debug window appearing on screen. (#1651).

docking
omar 6 years ago
parent a9a60a24c1
commit d845135273

@ -62,6 +62,10 @@ Other Changes:
This affects clamping window within the visible area: with this option enabled title bars need to be visible. (#899) This affects clamping window within the visible area: with this option enabled title bars need to be visible. (#899)
- Window: Fixed using SetNextWindowPos() on a child window (which wasn't really documented) position the cursor as expected - Window: Fixed using SetNextWindowPos() on a child window (which wasn't really documented) position the cursor as expected
in the parent window, so there is no mismatch between the layout in parent and the position of the child window. in the parent window, so there is no mismatch between the layout in parent and the position of the child window.
- Error recovery: Extraneous/undesired calls to End() are now being caught by an assert in the End() function itself
at the call site (instead of being reported in EndFrame). Past the assert, they don't lead to crashes any more. (#1651)
- Error recovery: Missing calls to End(), pass the assert, should not lead to crashes or to the fallback Debug window
appearing on screen, (#1651).
- IO: Added BackendPlatformUserData, BackendRendererUserData, BackendLanguageUserData void* for storage use by back-ends. - IO: Added BackendPlatformUserData, BackendRendererUserData, BackendLanguageUserData void* for storage use by back-ends.
- Style: Tweaked default value of style.DisplayWindowPadding from (20,20) to (19,19) so the default style as a value - Style: Tweaked default value of style.DisplayWindowPadding from (20,20) to (19,19) so the default style as a value
which is the same as the title bar height. which is the same as the title bar height.

@ -3555,6 +3555,9 @@ void ImGui::EndFrame()
return; return;
IM_ASSERT(g.FrameScopeActive && "Forgot to call ImGui::NewFrame()?"); IM_ASSERT(g.FrameScopeActive && "Forgot to call ImGui::NewFrame()?");
g.FrameScopeActive = false;
g.FrameCountEnded = g.FrameCount;
// Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME) // Notify OS when our Input Method Editor cursor has moved (e.g. CJK inputs using Microsoft IME)
if (g.IO.ImeSetInputScreenPosFn && ImLengthSqr(g.PlatformImeLastPos - g.PlatformImePos) > 0.0001f) if (g.IO.ImeSetInputScreenPosFn && ImLengthSqr(g.PlatformImeLastPos - g.PlatformImePos) > 0.0001f)
{ {
@ -3567,9 +3570,15 @@ void ImGui::EndFrame()
if (g.CurrentWindowStack.Size != 1) if (g.CurrentWindowStack.Size != 1)
{ {
if (g.CurrentWindowStack.Size > 1) if (g.CurrentWindowStack.Size > 1)
{
IM_ASSERT(g.CurrentWindowStack.Size == 1 && "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?"); IM_ASSERT(g.CurrentWindowStack.Size == 1 && "Mismatched Begin/BeginChild vs End/EndChild calls: did you forget to call End/EndChild?");
while (g.CurrentWindowStack.Size > 1) // FIXME-ERRORHANDLING
End();
}
else else
{
IM_ASSERT(g.CurrentWindowStack.Size == 1 && "Mismatched Begin/BeginChild vs End/EndChild calls: did you call End/EndChild too much?"); IM_ASSERT(g.CurrentWindowStack.Size == 1 && "Mismatched Begin/BeginChild vs End/EndChild calls: did you call End/EndChild too much?");
}
} }
// Hide implicit/fallback "Debug" window if it hasn't been used // Hide implicit/fallback "Debug" window if it hasn't been used
@ -3665,9 +3674,6 @@ void ImGui::EndFrame()
g.IO.MouseWheel = g.IO.MouseWheelH = 0.0f; g.IO.MouseWheel = g.IO.MouseWheelH = 0.0f;
memset(g.IO.InputCharacters, 0, sizeof(g.IO.InputCharacters)); memset(g.IO.InputCharacters, 0, sizeof(g.IO.InputCharacters));
memset(g.IO.NavInputs, 0, sizeof(g.IO.NavInputs)); memset(g.IO.NavInputs, 0, sizeof(g.IO.NavInputs));
g.FrameScopeActive = false;
g.FrameCountEnded = g.FrameCount;
} }
void ImGui::Render() void ImGui::Render()
@ -5251,6 +5257,13 @@ bool ImGui::Begin(const char* name, bool* p_open, const ImVec2& size_first_use,
void ImGui::End() void ImGui::End()
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
if (g.CurrentWindowStack.Size <= 1 && g.FrameScopeActive)
{
IM_ASSERT(g.CurrentWindowStack.Size > 1 && "Calling End() too many times!");
return; // FIXME-ERRORHANDLING
}
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
if (window->DC.ColumnsSet != NULL) if (window->DC.ColumnsSet != NULL)

Loading…
Cancel
Save