Skip to content

Commit 112d6d9

Browse files
committed
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.
1 parent 2c49da4 commit 112d6d9

2 files changed

Lines changed: 2 additions & 3 deletions

File tree

imgui.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15713,12 +15713,11 @@ void ImGui::CleanupIniSettings(ImGuiSettingsCleanupArgs* args)
1571315713
ImGuiContext& g = *GImGui;
1571415714
if (g.PlatformIO.Platform_SessionDate == 0)
1571515715
return;
15716-
ImGuiID type_hash_filter = args->TypeName ? ImHashStr(args->TypeName) : 0;
1571715716
ImGuiPackedDate discard_older_than_date_p = g.PlatformIO.Platform_SessionDate;
1571815717
discard_older_than_date_p.SubtractMonths(args->DiscardOlderThanMonths);
1571915718
args->_DiscardOlderThanDate = discard_older_than_date_p.Unpack();
1572015719
for (ImGuiSettingsHandler& handler : g.SettingsHandlers)
15721-
if (type_hash_filter == 0 || handler.TypeHash == type_hash_filter)
15720+
if (args->TypeHashFilter == 0 || handler.TypeHash == args->TypeHashFilter)
1572215721
if (handler.CleanupFn != NULL)
1572315722
handler.CleanupFn(&g, &handler, args);
1572415723
}

imgui_internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2048,7 +2048,7 @@ struct ImGuiWindowSettings
20482048

20492049
struct ImGuiSettingsCleanupArgs
20502050
{
2051-
const char* TypeName = NULL; // Set to restrict cleanup to a given .ini type, e.g. "Window", "Table". Otherwise every types supporting Cleanup are supported.
2051+
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.
20522052
int DiscardOlderThanMonths = 0; // Enable to discard entries older than XX months.
20532053
bool DiscardWhenMissingDate = false; // Enable to discard entries missing a date.
20542054
bool SetCurrentSessionDateToAll = false; // Enable to write current SessionDate to all supporting entries. // Let us know in #9460 if you use this.

0 commit comments

Comments
 (0)