diff options
author | Alessandro Portale <alessandro.portale@qt.io> | 2020-06-03 09:28:47 +0200 |
---|---|---|
committer | Alessandro Portale <alessandro.portale@qt.io> | 2020-06-04 06:59:57 +0000 |
commit | 81e0d9da11fde5e0bab012b53a1890b9bd34b4e8 (patch) | |
tree | 621af0610e6a5ff899d8b42ce0a73240d0c0bfba | |
parent | 777ae8b87b94b41e8af35ea786804bfc51e6c184 (diff) | |
download | qt-creator-81e0d9da11fde5e0bab012b53a1890b9bd34b4e8.tar.gz |
McuSupport: Fix a bug in the writing of settings
The plugin wants to only store settings if they differ from the defaults
(e.g. a path was edited by the user).
The original attempt failed. If the user changed the path, stored it,
and then changed the path back to the default, the last change was not
stored.
Therefore, this change actually removes the settings entry if it equals
either the default or the install settings value.
Task-number: QTCREATORBUG-24048
Change-Id: I6ab11f276ae270bb8bbf50ad6d2bc7ea3dba2d7b
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
-rw-r--r-- | src/plugins/mcusupport/mcusupportoptions.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/plugins/mcusupport/mcusupportoptions.cpp b/src/plugins/mcusupport/mcusupportoptions.cpp index bb10f7b064..96457170fa 100644 --- a/src/plugins/mcusupport/mcusupportoptions.cpp +++ b/src/plugins/mcusupport/mcusupportoptions.cpp @@ -167,12 +167,16 @@ bool McuPackage::addToPath() const void McuPackage::writeToSettings() const { - if (m_path.compare(m_defaultPath) == 0) - return; - QSettings *s = Core::ICore::settings(); - s->beginGroup(Constants::SETTINGS_GROUP); - s->setValue(QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + m_settingsKey, m_path); - s->endGroup(); + const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/' + + QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + m_settingsKey; + const QSettings *iS = Core::ICore::settings(QSettings::SystemScope); + QSettings *uS = Core::ICore::settings(); + if (m_path == m_defaultPath || ( + iS->contains(key) && + m_path == Utils::FilePath::fromUserInput(iS->value(key).toString()).toString())) + uS->remove(key); + else + uS->setValue(key, m_path); } void McuPackage::setRelativePathModifier(const QString &path) |