Browse Source

Fixes/amend 9825f7f + amend Changelog (#4857, #5937)

ocornut 2 years ago
parent
commit
844e0ae688
2 changed files with 7 additions and 3 deletions
  1. 1 0
      docs/CHANGELOG.txt
  2. 6 3
      imgui_draw.cpp

+ 1 - 0
docs/CHANGELOG.txt

@@ -42,6 +42,7 @@ Other changes:
 - Fixed cases where CTRL+Tab or Modal can occasionally lead to the creation of ImDrawCmd with
 - Fixed cases where CTRL+Tab or Modal can occasionally lead to the creation of ImDrawCmd with
   zero triangles, which would makes the render loop of some backends assert (e.g. Metal with
   zero triangles, which would makes the render loop of some backends assert (e.g. Metal with
   debugging, Allegro). (#4857, #5937)
   debugging, Allegro). (#4857, #5937)
+- Tables, Columns: Fixed cases where empty columns may lead to empty ImDrawCmd. (#4857, #5937)
 - Inputs, Scrolling: better selection of scrolling window when hovering nested windows
 - Inputs, Scrolling: better selection of scrolling window when hovering nested windows
   and when backend/OS is emitting dual-axis wheeling inputs (typically touch pads on macOS).
   and when backend/OS is emitting dual-axis wheeling inputs (typically touch pads on macOS).
   We now select a primary axis based on recent events, and select a target window based on it.
   We now select a primary axis based on recent events, and select a target window based on it.

+ 6 - 3
imgui_draw.cpp

@@ -447,10 +447,13 @@ void ImDrawList::AddDrawCmd()
 // Note that this leaves the ImDrawList in a state unfit for further commands, as most code assume that CmdBuffer.Size > 0 && CmdBuffer.back().UserCallback == NULL
 // Note that this leaves the ImDrawList in a state unfit for further commands, as most code assume that CmdBuffer.Size > 0 && CmdBuffer.back().UserCallback == NULL
 void ImDrawList::_PopUnusedDrawCmd()
 void ImDrawList::_PopUnusedDrawCmd()
 {
 {
-    if (CmdBuffer.Size == 0)
-        return;
-    for (ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1]; curr_cmd->ElemCount == 0 && curr_cmd->UserCallback == NULL; curr_cmd--)
+    while (CmdBuffer.Size > 0)
+    {
+        ImDrawCmd* curr_cmd = &CmdBuffer.Data[CmdBuffer.Size - 1];
+        if (curr_cmd->ElemCount != 0 || curr_cmd->UserCallback != NULL)
+            return;// break;
         CmdBuffer.pop_back();
         CmdBuffer.pop_back();
+    }
 }
 }
 
 
 void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data)
 void ImDrawList::AddCallback(ImDrawCallback callback, void* callback_data)