diff --git a/imgui_internal.h b/imgui_internal.h index 7f5e90dc0..c9ee4cbba 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -2048,7 +2048,8 @@ struct ImGuiWindowSettings struct ImGuiSettingsCleanupArgs { - int DiscardOlderThanMonths = 0; // Enable to discard entries older than XX months. + 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. bool SetCurrentSessionDateWhenMissingDate = false; // Enable to write current SessionDate to all supporting entries missing a date. // Let us know in #9460 if you use this. int _DiscardOlderThanDate = 0; // [Internal] diff --git a/imgui_tables.cpp b/imgui_tables.cpp index aa0b89efe..2fcce6cca 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -4134,9 +4134,12 @@ static void TableSettingsHandler_Cleanup(ImGuiContext* ctx, ImGuiSettingsHandler table->SettingsOffset = -1; for (ImGuiTableSettings* settings = g.SettingsTables.begin(); settings != NULL; settings = g.SettingsTables.next_chunk(settings)) { + const bool is_valid = settings->LastUsedDate.IsValid(); if (args->_DiscardOlderThanDate != 0 && settings->LastUsedDate.Unpack() < args->_DiscardOlderThanDate) settings->ID = 0; - if (args->SetCurrentSessionDateToAll || (args->SetCurrentSessionDateWhenMissingDate && settings->LastUsedDate.IsValid() == false)) + else if (args->DiscardWhenMissingDate && !is_valid) + settings->ID = 0; + else if (args->SetCurrentSessionDateToAll || (args->SetCurrentSessionDateWhenMissingDate && !is_valid)) settings->LastUsedDate = g.SessionDate; } }