From d15966ff6cb48adacaae2f6d40230b4194d8ea70 Mon Sep 17 00:00:00 2001 From: ocornut Date: Thu, 18 Jun 2026 19:19:38 +0200 Subject: [PATCH] Tables: fixed TableGcCompactSettings() not invalidating bound offset. A crash could in theory be triggered if clicking "Gc All" after saved tables have reduced column count. Tested by "table_settings_5" --- imgui.h | 2 +- imgui_tables.cpp | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/imgui.h b/imgui.h index ff9f0d9d7..720e3c8cd 100644 --- a/imgui.h +++ b/imgui.h @@ -30,7 +30,7 @@ // Library Version // (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345') #define IMGUI_VERSION "1.92.9 WIP" -#define IMGUI_VERSION_NUM 19283 +#define IMGUI_VERSION_NUM 19284 #define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000 #define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198 diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 12015ea99..a028e3b33 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -4110,7 +4110,7 @@ void ImGui::TableGcCompactTransientBuffers(ImGuiTableTempData* temp_data) temp_data->LastTimeActive = -1.0f; } -// Compact and remove unused settings data (currently only used by TestEngine) +// Compact and remove unused or resize settings data (only TestEngine mark unused, but resizing table down can lead to compaction) void ImGui::TableGcCompactSettings() { ImGuiContext& g = *GImGui; @@ -4126,6 +4126,9 @@ void ImGui::TableGcCompactSettings() if (settings->ID != 0) memcpy(new_chunk_stream.alloc_chunk(TableSettingsCalcChunkSize(settings->ColumnsCount)), settings, TableSettingsCalcChunkSize(settings->ColumnsCount)); g.SettingsTables.swap(new_chunk_stream); + for (int table_n = 0; table_n < g.Tables.GetMapSize(); table_n++) + if (ImGuiTable* table = g.Tables.TryGetMapData(table_n)) + table->SettingsOffset = -1; }