forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -167,12 +167,16 @@ bool McuPackage::addToPath() const
|
|||||||
|
|
||||||
void McuPackage::writeToSettings() const
|
void McuPackage::writeToSettings() const
|
||||||
{
|
{
|
||||||
if (m_path.compare(m_defaultPath) == 0)
|
const QString key = QLatin1String(Constants::SETTINGS_GROUP) + '/' +
|
||||||
return;
|
QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + m_settingsKey;
|
||||||
QSettings *s = Core::ICore::settings();
|
const QSettings *iS = Core::ICore::settings(QSettings::SystemScope);
|
||||||
s->beginGroup(Constants::SETTINGS_GROUP);
|
QSettings *uS = Core::ICore::settings();
|
||||||
s->setValue(QLatin1String(Constants::SETTINGS_KEY_PACKAGE_PREFIX) + m_settingsKey, m_path);
|
if (m_path == m_defaultPath || (
|
||||||
s->endGroup();
|
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)
|
void McuPackage::setRelativePathModifier(const QString &path)
|
||||||
|
Reference in New Issue
Block a user