Clean up persisted windows after the feature is disabled (#18910)

I finally realized the missing piece.
We need to clear the state array unconditionally,
as otherwise it won't get cleared. Duh.

Closes #18584

## Validation Steps Performed
* Craft a state.json with a layout
* Launch Terminal while the feature is disabled
* state.json is cleaned up on exit 
This commit is contained in:
Leonard Hecker 2025-05-14 19:04:13 +02:00 committed by GitHub
parent 14993db1cb
commit 69fc2d94ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -925,9 +925,15 @@ void WindowEmperor::_finalizeSessionPersistence() const
{
const auto state = ApplicationState::SharedInstance();
if (_forcePersistence || _app.Logic().Settings().GlobalSettings().ShouldUsePersistedLayout())
// Calling an `ApplicationState` setter triggers a write to state.json.
// With this if condition we avoid an unnecessary write when persistence is disabled.
if (state.PersistedWindowLayouts())
{
state.PersistedWindowLayouts(nullptr);
}
if (_forcePersistence || _app.Logic().Settings().GlobalSettings().ShouldUsePersistedLayout())
{
for (const auto& w : _windows)
{
w->Logic().PersistState();