summaryrefslogtreecommitdiffhomepage
path: root/migration/migration.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2017-05-06 13:15:16 +0200
committerStanislaw Halik <sthalik@misaki.pl>2017-05-10 11:19:22 +0200
commit87c09c0ab5e1334e9877ee6fd7adeb1eb70d5929 (patch)
tree3f407f9d0fc947427729913cf60e2e5f9b962ce0 /migration/migration.cpp
parent604914db84d0468c6c8d04dfe6491e3c15b670f7 (diff)
options: don't create QSettings all the time
Update usages.
Diffstat (limited to 'migration/migration.cpp')
-rw-r--r--migration/migration.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/migration/migration.cpp b/migration/migration.cpp
index bb8386fc..747ea06b 100644
--- a/migration/migration.cpp
+++ b/migration/migration.cpp
@@ -78,11 +78,11 @@ QString migrator::last_migration_time()
{
QString ret;
- std::shared_ptr<QSettings> s(options::group::ini_file());
-
- s->beginGroup("migrations");
- ret = s->value("last-migration-at", "19700101_00").toString();
- s->endGroup();
+ options::group::with_settings_object([&](QSettings& s) {
+ s.beginGroup("migrations");
+ ret = s.value("last-migration-at", "19700101_00").toString();
+ s.endGroup();
+ });
return ret;
}
@@ -102,11 +102,16 @@ QString migrator::time_after_migrations()
void migrator::set_last_migration_time(const QString& val)
{
- std::shared_ptr<QSettings> s(options::group::ini_file());
-
- s->beginGroup("migrations");
- s->setValue("last-migration-at", val);
- s->endGroup();
+ options::group::with_settings_object([&](QSettings& s) {
+ s.beginGroup("migrations");
+ const QString old_value = s.value("last-migration-at", "").toString();
+ if (val != old_value)
+ {
+ s.setValue("last-migration-at", val);
+ options::group::mark_ini_modified();
+ }
+ s.endGroup();
+ });
}
std::vector<migration*> migrator::sorted_migrations()