Bläddra i källkod

Error Handling: added better error report and recovery when calling EndFrame() or Render() without NewFrame().

ocornut 4 månader sedan
förälder
incheckning
7ab4728a36
2 ändrade filer med 7 tillägg och 1 borttagningar
  1. 2 0
      docs/CHANGELOG.txt
  2. 5 1
      imgui.cpp

+ 2 - 0
docs/CHANGELOG.txt

@@ -80,6 +80,8 @@ Other changes:
   CTRL+Tab windowing + pressing a keyboard key. (#8525)
   CTRL+Tab windowing + pressing a keyboard key. (#8525)
 - Error Handling: added better error report and recovery for extraneous
 - Error Handling: added better error report and recovery for extraneous
   EndPopup() call. (#1651, #8499)
   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: word-wrapping code handle ideographic comma & full stop (U+3001, U+3002). (#8540)
 - Fonts: fixed CalcWordWrapPositionA() fallback when width is too small to wrap:
 - 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)
   would use a +1 offset instead of advancing to the next UTF-8 codepoint. (#8540)

+ 5 - 1
imgui.cpp

@@ -5641,7 +5641,11 @@ void ImGui::EndFrame()
     // Don't process EndFrame() multiple times.
     // Don't process EndFrame() multiple times.
     if (g.FrameCountEnded == g.FrameCount)
     if (g.FrameCountEnded == g.FrameCount)
         return;
         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);
     CallContextHooks(&g, ImGuiContextHookType_EndFramePre);