Commit c0eaed86 authored by Eike Ziller's avatar Eike Ziller

Improve performance of writing settings

By wrapping related ones in a single transaction, instead of
(implicitly) doing a transaction per settings value that is written.

Task-number: QTCREATORBUG-11524
Change-Id: I28e06c9d6cd4ebad024f9c277796abb37df5f992
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
Reviewed-by: default avatarJoerg Bornemann <joerg.bornemann@digia.com>
parent a471d3ae
......@@ -2287,10 +2287,12 @@ static const char autoSaveIntervalKey[] = "EditorManager/AutoSaveInterval";
void EditorManager::saveSettings()
{
SettingsDatabase *settings = ICore::settingsDatabase();
settings->beginTransaction();
settings->setValue(QLatin1String(documentStatesKey), d->m_editorStates);
settings->setValue(QLatin1String(reloadBehaviorKey), d->m_reloadSetting);
settings->setValue(QLatin1String(autoSaveEnabledKey), d->m_autoSaveEnabled);
settings->setValue(QLatin1String(autoSaveIntervalKey), d->m_autoSaveInterval);
settings->endTransaction();
}
void EditorManager::readSettings()
......
......@@ -186,6 +186,7 @@ void Locator::saveSettings()
{
if (m_settingsInitialized) {
SettingsDatabase *s = ICore::settingsDatabase();
s->beginTransaction();
s->beginGroup(QLatin1String("QuickOpen"));
s->remove(QString());
s->setValue(QLatin1String("RefreshInterval"), refreshInterval());
......@@ -202,6 +203,7 @@ void Locator::saveSettings()
}
s->endGroup();
s->endGroup();
s->endTransaction();
}
}
......
......@@ -252,6 +252,20 @@ QStringList SettingsDatabase::childKeys() const
return children;
}
void SettingsDatabase::beginTransaction()
{
if (!d->m_db.isOpen())
return;
d->m_db.exec(QLatin1String("BEGIN TRANSACTION;"));
}
void SettingsDatabase::endTransaction()
{
if (!d->m_db.isOpen())
return;
d->m_db.exec(QLatin1String("END TRANSACTION;"));
}
void SettingsDatabase::sync()
{
// TODO: Delay writing of dirty keys and save them here
......
......@@ -57,6 +57,9 @@ public:
QString group() const;
QStringList childKeys() const;
void beginTransaction();
void endTransaction();
void sync();
private:
......
......@@ -150,6 +150,7 @@ void UpdateInfoPlugin::saveSettings()
{
SettingsDatabase *settings = ICore::settingsDatabase();
if (settings) {
settings->beginTransaction();
settings->beginGroup(QLatin1String("Updater"));
settings->setValue(QLatin1String("Application"), d->updaterProgram);
settings->setValue(QLatin1String("LastDayChecked"), d->m_lastDayChecked);
......@@ -157,6 +158,7 @@ void UpdateInfoPlugin::saveSettings()
settings->setValue(QLatin1String("CheckOnlyArgument"), d->updaterCheckOnlyArgument);
settings->setValue(QLatin1String("ScheduledUpdateTime"), d->m_scheduledUpdateTime);
settings->endGroup();
settings->endTransaction();
}
}
......
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