From e281b667c6daf38cfff66d6b4967d8550eab2133 Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 17 Jul 2022 12:41:18 +0800 Subject: [PATCH] Properly release settings class before further operations Fix up d3e7e8a6304c080d143565bb6416b467fc48e6cf. PR #17376. --- src/base/settingsstorage.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/base/settingsstorage.cpp b/src/base/settingsstorage.cpp index da3c9d374..09ee2fc99 100644 --- a/src/base/settingsstorage.cpp +++ b/src/base/settingsstorage.cpp @@ -172,8 +172,12 @@ bool SettingsStorage::writeNativeSettings() const nativeSettings->setValue(i.key(), i.value()); nativeSettings->sync(); // Important to get error status + const QSettings::Status status = nativeSettings->status(); + const Path newPath {nativeSettings->fileName()}; + + nativeSettings.reset(); // close QSettings - switch (nativeSettings->status()) + switch (status) { case QSettings::NoError: break; @@ -188,8 +192,7 @@ bool SettingsStorage::writeNativeSettings() const break; } - const Path newPath {nativeSettings->fileName()}; - if (nativeSettings->status() != QSettings::NoError) + if (status != QSettings::NoError) { Utils::Fs::removeFile(newPath); return false;