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"
This commit is contained in:
ocornut
2026-06-18 19:19:38 +02:00
parent 9a5c070308
commit d15966ff6c
2 changed files with 5 additions and 2 deletions

View File

@@ -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

View File

@@ -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;
}