From 112d6d9eabe3995e0cfa0a093e287c68f865d3f1 Mon Sep 17 00:00:00 2001 From: ocornut Date: Tue, 7 Jul 2026 22:30:15 +0200 Subject: [PATCH] Settings: added a type name filter to CleanupIniSettings() / ImGuiSettingsCleanupArgs. Amends. (#9460) Request hash because storing const char* strings in struct is not entirely zen. Amend 2c49da4. --- imgui.cpp | 3 +-- imgui_internal.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 3a43223e1..43409848e 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -15713,12 +15713,11 @@ void ImGui::CleanupIniSettings(ImGuiSettingsCleanupArgs* args) ImGuiContext& g = *GImGui; if (g.PlatformIO.Platform_SessionDate == 0) return; - ImGuiID type_hash_filter = args->TypeName ? ImHashStr(args->TypeName) : 0; ImGuiPackedDate discard_older_than_date_p = g.PlatformIO.Platform_SessionDate; discard_older_than_date_p.SubtractMonths(args->DiscardOlderThanMonths); args->_DiscardOlderThanDate = discard_older_than_date_p.Unpack(); for (ImGuiSettingsHandler& handler : g.SettingsHandlers) - if (type_hash_filter == 0 || handler.TypeHash == type_hash_filter) + if (args->TypeHashFilter == 0 || handler.TypeHash == args->TypeHashFilter) if (handler.CleanupFn != NULL) handler.CleanupFn(&g, &handler, args); } diff --git a/imgui_internal.h b/imgui_internal.h index 33f3ad756..a4be1621a 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -2048,7 +2048,7 @@ struct ImGuiWindowSettings struct ImGuiSettingsCleanupArgs { - const char* TypeName = NULL; // Set to restrict cleanup to a given .ini type, e.g. "Window", "Table". Otherwise every types supporting Cleanup are supported. + ImGuiID TypeHashFilter = 0; // Set to restrict cleanup to a given .ini type, e.g. == ImHashStr("Window"), ImHashStr("Table"). Otherwise every types supporting Cleanup will be affected. int DiscardOlderThanMonths = 0; // Enable to discard entries older than XX months. bool DiscardWhenMissingDate = false; // Enable to discard entries missing a date. bool SetCurrentSessionDateToAll = false; // Enable to write current SessionDate to all supporting entries. // Let us know in #9460 if you use this.