From 83d22f4e480c6f71ffc1514c2453feed0fce2733 Mon Sep 17 00:00:00 2001 From: Jonathan Hoffstadt Date: Thu, 30 Dec 2021 14:37:31 -0600 Subject: [PATCH] Tables, ImDrawListSplitter: Fixed erroneously stripping trailing ImDrawList::AddCallback().(#4843, #4844) --- docs/CHANGELOG.txt | 2 ++ imgui_draw.cpp | 4 +--- imgui_tables.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 9767f0baa..11c4e5553 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -35,6 +35,8 @@ HOW TO UPDATE? VERSION 1.87 WIP (In Progress) ----------------------------------------------------------------------- +- Tables, ImDrawListSplitter: Fixed erroneously stripping trailing ImDrawList::AddCallback() when submitted in + last column or last channel and when there are no other drawing operation. (#4843, #4844) [@hoffstadt] - Backends: OpenGL3: Fixed a buffer overflow in imgui_impl_opengl3_loader.h init (added in 1.86). (#4468, #4830) [@dymk] It would generally not have noticeable side-effect at runtime but would be detected by runtime checkers. - Backends: Metal: Added Apple Metal C++ API support. (#4824, #4746) [@luigifcruz] diff --git a/imgui_draw.cpp b/imgui_draw.cpp index c147bfda2..423f8cd27 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -1733,9 +1733,7 @@ void ImDrawListSplitter::Merge(ImDrawList* draw_list) for (int i = 1; i < _Count; i++) { ImDrawChannel& ch = _Channels[i]; - - // Equivalent of PopUnusedDrawCmd() for this channel's cmdbuffer and except we don't need to test for UserCallback. - if (ch._CmdBuffer.Size > 0 && ch._CmdBuffer.back().ElemCount == 0) + if (ch._CmdBuffer.Size > 0 && ch._CmdBuffer.back().ElemCount == 0 && ch._CmdBuffer.back().UserCallback == NULL) // Equivalent of PopUnusedDrawCmd() ch._CmdBuffer.pop_back(); if (ch._CmdBuffer.Size > 0 && last_cmd != NULL) diff --git a/imgui_tables.cpp b/imgui_tables.cpp index b5c9c2f27..88717bd56 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -2353,7 +2353,7 @@ void ImGui::TableMergeDrawChannels(ImGuiTable* table) // Don't attempt to merge if there are multiple draw calls within the column ImDrawChannel* src_channel = &splitter->_Channels[channel_no]; - if (src_channel->_CmdBuffer.Size > 0 && src_channel->_CmdBuffer.back().ElemCount == 0) + if (src_channel->_CmdBuffer.Size > 0 && src_channel->_CmdBuffer.back().ElemCount == 0 && src_channel->_CmdBuffer.back().UserCallback != NULL) // Equivalent of PopUnusedDrawCmd() src_channel->_CmdBuffer.pop_back(); if (src_channel->_CmdBuffer.Size != 1) continue;