Settings: added explicit DiscardWhenMissingDate. (#9460, #9108)

This commit is contained in:
ocornut
2026-07-07 22:00:26 +02:00
parent 481f2cea17
commit d1eb8d031c
2 changed files with 6 additions and 2 deletions

View File

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

View File

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