From 7ab4728a36cfa99c9a5cffde758f86248accb5b3 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 16 Apr 2025 18:12:53 +0200 Subject: [PATCH] Error Handling: added better error report and recovery when calling EndFrame() or Render() without NewFrame(). --- docs/CHANGELOG.txt | 2 ++ imgui.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index e4e8dc0db..51229ac83 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -80,6 +80,8 @@ Other changes: CTRL+Tab windowing + pressing a keyboard key. (#8525) - Error Handling: added better error report and recovery for extraneous EndPopup() call. (#1651, #8499) +- Error Handling: added better error report and recovery when calling EndFrame() + or Render() without NewFrame(). Was previously only an assert. - Fonts: word-wrapping code handle ideographic comma & full stop (U+3001, U+3002). (#8540) - Fonts: fixed CalcWordWrapPositionA() fallback when width is too small to wrap: would use a +1 offset instead of advancing to the next UTF-8 codepoint. (#8540) diff --git a/imgui.cpp b/imgui.cpp index a8d67f9bf..0d882da04 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -5641,7 +5641,11 @@ void ImGui::EndFrame() // Don't process EndFrame() multiple times. if (g.FrameCountEnded == g.FrameCount) return; - IM_ASSERT(g.WithinFrameScope && "Forgot to call ImGui::NewFrame()?"); + if (!g.WithinFrameScope) + { + IM_ASSERT_USER_ERROR(g.WithinFrameScope, "Forgot to call ImGui::NewFrame()?"); + return; + } CallContextHooks(&g, ImGuiContextHookType_EndFramePre);