From 548389359c4b2edfcc3b7d48d8750e324ebdc82a Mon Sep 17 00:00:00 2001 From: ocornut Date: Mon, 20 Jul 2026 16:42:07 +0200 Subject: [PATCH] (Breaking) ImDrawData: marked draw_data->CmdListsCount as obsolete. Use draw_data->CmdLists.Size. # Conflicts: # docs/CHANGELOG.txt # imgui.cpp --- docs/CHANGELOG.txt | 9 ++++++--- imgui.cpp | 12 +++++++++--- imgui.h | 5 ++++- imgui_draw.cpp | 10 +++++++--- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index 2c88d5706..0dec2215e 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -53,7 +53,8 @@ Breaking Changes: Before: DragFloat() with user typing "123" --> write back 1, then 12, then 123. After: DragFloat() with user typing "123" --> write back 123 when validated/unfocused. You can enable the flag back for a given scope if needed by specific widget/behavior. - +- ImDrawData: marked `CmdListsCount` as obsolete (technically was obsoleted in 1.89.8). + Before: `draw_data->CmdListsCount`, After: `draw_data->CmdLists.Size`. Other Changes: @@ -3541,8 +3542,10 @@ Breaking changes: input queue. This is automatically cleared by io.ClearInputKeys(). (#4921) - ImDrawData: CmdLists[] array is now owned, changed from 'ImDrawList**' to 'ImVector'. Majority of users shouldn't be affected, but you - cannot compare to NULL nor reassign manually anymore. - Instead use AddDrawList(). Allocation count are identical. (#6406, #4879, #1878) + cannot compare to NULL nor reassign manually anymore. (#6406, #4879, #1878) + - Allocation count are identical. + - Use `draw_data->CmdLists.Size` instead of `draw_list->CmdListsCount`! + - Use `AddDrawList()` to add to a `ImDrawData`. Other changes: diff --git a/imgui.cpp b/imgui.cpp index ba8236e2b..2e97af26b 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -400,6 +400,9 @@ IMPLEMENTING SUPPORT for ImGuiBackendFlags_RendererHasTextures: - Before: DragFloat() with user typing "123" --> write back 1, then 12, then 123. - After: DragFloat() with user typing "123" --> write back 123 when validated/unfocused. You can enable the flag back for a given scope if needed by specific widget/behavior. + - 2026/07/20 (1.92.9) - ImDrawData: marked ImDrawData::CmdListsCount as obsolete (technically was obsoleted in 1.89.8). + - Before: draw_data->CmdListsCount + - After: draw_data->CmdLists.Size - 2026/07/08 (1.92.9) - Drag and Drop: commented out legacy name `ImGuiDragDropFlags_SourceAutoExpirePayload` which obsoleted in 1.90.9 (July 2024). Use `ImGuiDragDropFlags_PayloadAutoExpire`. - 2026/07/06 (1.92.9) - ColorEdit: obsoleted SetColorEditOptions() function added in 1.51 (June 2017) in favor of directly poking to io.ConfigColorEditFlags. More consistent and easier to discover. - 2026/06/02 (1.92.9) - TreeNode: commented out legacy name ImGuiTreeNodeFlags_SpanTextWidth which was obsoleted in 1.90.7 (May 2024). Use ImGuiTreeNodeFlags_SpanLabelWidth instead. @@ -736,7 +739,9 @@ IMPLEMENTING SUPPORT for ImGuiBackendFlags_RendererHasTextures: - ImDrawCornerFlags_XXX -> use ImDrawFlags_RoundCornersXXX flags. Read 1.82 Changelog for details + grep commented names in sources. - commented out runtime support for hardcoded ~0 or 0x01..0x0F rounding flags values for AddRect()/AddRectFilled()/PathRect()/AddImageRounded() -> use ImDrawFlags_RoundCornersXXX flags. Read 1.82 Changelog for details - 2023/08/25 (1.89.9) - clipper: Renamed IncludeRangeByIndices() (also called ForceDisplayRangeByIndices() before 1.89.6) to IncludeItemsByIndex(). Kept inline redirection function. Sorry! - - 2023/07/12 (1.89.8) - ImDrawData: CmdLists now owned, changed from ImDrawList** to ImVector. Majority of users shouldn't be affected, but you cannot compare to NULL nor reassign manually anymore. Instead use AddDrawList(). (#6406, #4879, #1878) + - 2023/07/12 (1.89.8) - ImDrawData: CmdLists now owned, changed from ImDrawList** to ImVector. Majority of users shouldn't be affected, but you cannot compare to NULL nor reassign manually anymore. (#6406, #4879, #1878) + - use `draw_data->CmdLists.Size` instead of `draw_list->CmdListsCount`. + - use `draw_data->AddDrawList()` to add to a ImDrawData. - 2023/06/28 (1.89.7) - overlapping items: obsoleted 'SetItemAllowOverlap()' (called after item) in favor of calling 'SetNextItemAllowOverlap()' (called before item). 'SetItemAllowOverlap()' didn't and couldn't work reliably since 1.89 (2022-11-15). - 2023/06/28 (1.89.7) - overlapping items: renamed 'ImGuiTreeNodeFlags_AllowItemOverlap' to 'ImGuiTreeNodeFlags_AllowOverlap', 'ImGuiSelectableFlags_AllowItemOverlap' to 'ImGuiSelectableFlags_AllowOverlap'. Kept redirecting enums (will obsolete). - 2023/06/28 (1.89.7) - overlapping items: IsItemHovered() now by default return false when querying an item using AllowOverlap mode which is being overlapped. Use ImGuiHoveredFlags_AllowWhenOverlappedByItem to revert to old behavior. @@ -5958,13 +5963,15 @@ static void InitViewportDrawData(ImGuiViewportP* viewport) viewport->DrawDataBuilder.Layers[1]->resize(0); draw_data->Valid = true; - draw_data->CmdListsCount = 0; draw_data->TotalVtxCount = draw_data->TotalIdxCount = 0; draw_data->DisplayPos = viewport->Pos; draw_data->DisplaySize = viewport->Size; draw_data->FramebufferScale = io.DisplayFramebufferScale; draw_data->OwnerViewport = viewport; draw_data->Textures = &ImGui::GetPlatformIO().Textures; +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + draw_data->CmdListsCount = 0; +#endif } // Push a clipping rectangle for both ImGui logic (hit-testing etc.) and low-level ImDrawList rendering. @@ -6232,7 +6239,6 @@ void ImGui::Render() // We call _PopUnusedDrawCmd() last thing, as RenderDimmedBackgrounds() rely on a valid command being there (especially in docking branch). ImDrawData* draw_data = &viewport->DrawDataP; - IM_ASSERT(draw_data->CmdLists.Size == draw_data->CmdListsCount); for (ImDrawList* draw_list : draw_data->CmdLists) draw_list->_PopUnusedDrawCmd(); diff --git a/imgui.h b/imgui.h index 642fcb906..d219d5a6d 100644 --- a/imgui.h +++ b/imgui.h @@ -3493,7 +3493,6 @@ struct ImDrawList struct ImDrawData { bool Valid; // Only valid after Render() is called and before the next NewFrame() is called. - int CmdListsCount; // == CmdLists.Size. (OBSOLETE: exists for legacy reasons). Number of ImDrawList* to render. int TotalIdxCount; // For convenience, sum of all ImDrawList's IdxBuffer.Size int TotalVtxCount; // For convenience, sum of all ImDrawList's VtxBuffer.Size ImVector CmdLists; // Array of ImDrawList* to render. The ImDrawLists are owned by ImGuiContext and only pointed to from here. @@ -3503,6 +3502,10 @@ struct ImDrawData ImGuiViewport* OwnerViewport; // Viewport carrying the ImDrawData instance, might be of use to the renderer (generally not). ImVector* Textures; // List of textures to update. Most of the times the list is shared by all ImDrawData, has only 1 texture and it doesn't need any update. This almost always points to ImGui::GetPlatformIO().Textures[]. May be overridden or set to NULL if you want to manually update textures. +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + int CmdListsCount; // Use CmdLists.Size instead. Number of ImDrawList* to render. +#endif + // Functions ImDrawData() { Clear(); } IMGUI_API void Clear(); diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 4a68ff4a8..d95dc20ad 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -2280,11 +2280,14 @@ void ImDrawListSplitter::SetCurrentChannel(ImDrawList* draw_list, int idx) void ImDrawData::Clear() { Valid = false; - CmdListsCount = TotalIdxCount = TotalVtxCount = 0; + TotalIdxCount = TotalVtxCount = 0; CmdLists.resize(0); // The ImDrawList are NOT owned by ImDrawData but e.g. by ImGuiContext, so we don't clear them. DisplayPos = DisplaySize = FramebufferScale = ImVec2(0.0f, 0.0f); OwnerViewport = NULL; Textures = NULL; +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + CmdListsCount = 0; +#endif } // Important: 'out_list' is generally going to be draw_data->CmdLists, but may be another temporary list @@ -2329,16 +2332,17 @@ void ImGui::AddDrawListToDrawDataEx(ImDrawData* draw_data, ImVector // Add to output list + records state in ImDrawData out_list->push_back(draw_list); - draw_data->CmdListsCount++; draw_data->TotalVtxCount += draw_list->VtxBuffer.Size; draw_data->TotalIdxCount += draw_list->IdxBuffer.Size; } void ImDrawData::AddDrawList(ImDrawList* draw_list) { - IM_ASSERT(CmdLists.Size == CmdListsCount); draw_list->_PopUnusedDrawCmd(); ImGui::AddDrawListToDrawDataEx(this, &CmdLists, draw_list); +#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS + CmdListsCount = CmdLists.Size; +#endif } // For backward compatibility: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!