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"; ...@@ -2287,10 +2287,12 @@ static const char autoSaveIntervalKey[] = "EditorManager/AutoSaveInterval";
void EditorManager::saveSettings() void EditorManager::saveSettings()
{ {
SettingsDatabase *settings = ICore::settingsDatabase(); SettingsDatabase *settings = ICore::settingsDatabase();
settings->beginTransaction();
settings->setValue(QLatin1String(documentStatesKey), d->m_editorStates); settings->setValue(QLatin1String(documentStatesKey), d->m_editorStates);
settings->setValue(QLatin1String(reloadBehaviorKey), d->m_reloadSetting); settings->setValue(QLatin1String(reloadBehaviorKey), d->m_reloadSetting);
settings->setValue(QLatin1String(autoSaveEnabledKey), d->m_autoSaveEnabled); settings->setValue(QLatin1String(autoSaveEnabledKey), d->m_autoSaveEnabled);
settings->setValue(QLatin1String(autoSaveIntervalKey), d->m_autoSaveInterval); settings->setValue(QLatin1String(autoSaveIntervalKey), d->m_autoSaveInterval);
settings->endTransaction();
} }
void EditorManager::readSettings() void EditorManager::readSettings()
......
...@@ -186,6 +186,7 @@ void Locator::saveSettings() ...@@ -186,6 +186,7 @@ void Locator::saveSettings()
{ {
if (m_settingsInitialized) { if (m_settingsInitialized) {
SettingsDatabase *s = ICore::settingsDatabase(); SettingsDatabase *s = ICore::settingsDatabase();
s->beginTransaction();
s->beginGroup(QLatin1String("QuickOpen")); s->beginGroup(QLatin1String("QuickOpen"));
s->remove(QString()); s->remove(QString());
s->setValue(QLatin1String("RefreshInterval"), refreshInterval()); s->setValue(QLatin1String("RefreshInterval"), refreshInterval());
...@@ -202,6 +203,7 @@ void Locator::saveSettings() ...@@ -202,6 +203,7 @@ void Locator::saveSettings()
} }
s->endGroup(); s->endGroup();
s->endGroup(); s->endGroup();
s->endTransaction();
} }
} }
......
...@@ -252,6 +252,20 @@ QStringList SettingsDatabase::childKeys() const ...@@ -252,6 +252,20 @@ QStringList SettingsDatabase::childKeys() const
return children; 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() void SettingsDatabase::sync()
{ {
// TODO: Delay writing of dirty keys and save them here // TODO: Delay writing of dirty keys and save them here
......
...@@ -57,6 +57,9 @@ public: ...@@ -57,6 +57,9 @@ public:
QString group() const; QString group() const;
QStringList childKeys() const; QStringList childKeys() const;
void beginTransaction();
void endTransaction();
void sync(); void sync();
private: private:
......
...@@ -150,6 +150,7 @@ void UpdateInfoPlugin::saveSettings() ...@@ -150,6 +150,7 @@ void UpdateInfoPlugin::saveSettings()
{ {
SettingsDatabase *settings = ICore::settingsDatabase(); SettingsDatabase *settings = ICore::settingsDatabase();
if (settings) { if (settings) {
settings->beginTransaction();
settings->beginGroup(QLatin1String("Updater")); settings->beginGroup(QLatin1String("Updater"));
settings->setValue(QLatin1String("Application"), d->updaterProgram); settings->setValue(QLatin1String("Application"), d->updaterProgram);
settings->setValue(QLatin1String("LastDayChecked"), d->m_lastDayChecked); settings->setValue(QLatin1String("LastDayChecked"), d->m_lastDayChecked);
...@@ -157,6 +158,7 @@ void UpdateInfoPlugin::saveSettings() ...@@ -157,6 +158,7 @@ void UpdateInfoPlugin::saveSettings()
settings->setValue(QLatin1String("CheckOnlyArgument"), d->updaterCheckOnlyArgument); settings->setValue(QLatin1String("CheckOnlyArgument"), d->updaterCheckOnlyArgument);
settings->setValue(QLatin1String("ScheduledUpdateTime"), d->m_scheduledUpdateTime); settings->setValue(QLatin1String("ScheduledUpdateTime"), d->m_scheduledUpdateTime);
settings->endGroup(); 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