Commit 9acb8fa9 authored by Tobias Hunger's avatar Tobias Hunger

SettingsAccessor: Inline writeFile, it's only called once

Change-Id: Iba22b820ce5b671a924757d5a24900e20f8c46ae
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 8b1728d8
......@@ -649,7 +649,22 @@ bool SettingsAccessor::saveSettings(const QVariantMap &map, QWidget *parent) con
if (shared.isValid())
trackUserStickySettings(settings.m_map, shared.toMap());
return writeFile(&settings, parent);
if (!d->m_writer || d->m_writer->fileName() != settings.fileName()) {
delete d->m_writer;
d->m_writer = new PersistentSettingsWriter(settings.fileName(), QLatin1String("QtCreatorProject"));
}
QVariantMap data;
for (QVariantMap::const_iterator i = settings.m_map.constBegin();
i != settings.m_map.constEnd();
++i) {
data.insert(i.key(), i.value());
}
data.insert(QLatin1String(VERSION_KEY), m_lastVersion + 1);
data.insert(QLatin1String(ENVIRONMENT_ID_KEY), SettingsAccessor::creatorId());
return d->m_writer->save(data, parent);
}
void SettingsAccessor::addVersionUpgrader(VersionUpgrader *handler)
......@@ -931,26 +946,6 @@ QVariantMap SettingsAccessor::readFile(const Utils::FileName &path) const
return reader.restoreValues();
}
bool SettingsAccessor::writeFile(const SettingsData *settings, QWidget *parent) const
{
if (!d->m_writer || d->m_writer->fileName() != settings->fileName()) {
delete d->m_writer;
d->m_writer = new PersistentSettingsWriter(settings->fileName(), QLatin1String("QtCreatorProject"));
}
QVariantMap data;
for (QVariantMap::const_iterator i = settings->m_map.constBegin();
i != settings->m_map.constEnd();
++i) {
data.insert(i.key(), i.value());
}
data.insert(QLatin1String(VERSION_KEY), m_lastVersion + 1);
data.insert(QLatin1String(ENVIRONMENT_ID_KEY), SettingsAccessor::creatorId());
return d->m_writer->save(data, parent);
}
// -------------------------------------------------------------------------
// UserFileVersion1Upgrader:
// -------------------------------------------------------------------------
......
......@@ -90,7 +90,6 @@ private:
QVariantMap mergeSettings(const QVariantMap &userMap, const QVariantMap &sharedMap) const;
QVariantMap readFile(const Utils::FileName &path) const;
bool writeFile(const SettingsData *settings, QWidget *parent) const;
static QByteArray environmentIdFromMap(const QVariantMap &data);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment