diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2018-07-08 23:29:49 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2018-07-08 23:29:49 +0200 |
commit | fa1801471c2708ed8266ec7b99bd4cec886ccc1b (patch) | |
tree | aa56218c2c7e4939aaf11a2046b0f12760326545 /migration | |
parent | 90940a774eab876c38d5cef981b4be5bae67a462 (diff) |
options: fix 2 issues
1. Calling valueChanged didn't invoke machinery in
value<t>, only base_value aka value_.
There's a fast path in value<t>::type() despite the
pessimization.
2. Split global scope stuff into options::globals from
the options::globals stuff
3. Adjust usages
Diffstat (limited to 'migration')
-rw-r--r-- | migration/20160906_00-mappings.cpp | 5 | ||||
-rw-r--r-- | migration/20180102_00-process-detector-separator.cpp | 5 | ||||
-rw-r--r-- | migration/migration.cpp | 42 |
3 files changed, 27 insertions, 25 deletions
diff --git a/migration/20160906_00-mappings.cpp b/migration/20160906_00-mappings.cpp index 0019d0ef..f94f8290 100644 --- a/migration/20160906_00-mappings.cpp +++ b/migration/20160906_00-mappings.cpp @@ -19,6 +19,7 @@ #include <QDebug> using namespace options; +using namespace options::globals; using namespace migrations; static const char* const old_names[] = @@ -44,7 +45,7 @@ static QList<QList<QPointF>> get_old_splines() { QList<QList<QPointF>> ret; - return group::with_settings_object([&](QSettings& settings) { + return with_settings_object([&](QSettings& settings) { for (const char* name : old_names) { const int max = settings.value("point-count", 0).toInt(); @@ -96,7 +97,7 @@ struct mappings_from_2_3_0_rc11 : migration void run() override { - group::with_settings_object([this](QSettings&) { + with_settings_object([](QSettings&) { const QList<QList<QPointF>> old_mappings = get_old_splines(); for (int i = 0; i < 12; i++) diff --git a/migration/20180102_00-process-detector-separator.cpp b/migration/20180102_00-process-detector-separator.cpp index ddb01cb4..6c3a2b58 100644 --- a/migration/20180102_00-process-detector-separator.cpp +++ b/migration/20180102_00-process-detector-separator.cpp @@ -2,6 +2,7 @@ #include "options/options.hpp" using namespace options; +using namespace options::globals; using namespace migrations; static constexpr auto OLD_RECORD_SEPARATOR = QChar('|'); @@ -26,7 +27,7 @@ struct process_detector_record_separator : migration bool should_run() const override { - return group::with_global_settings_object([](const QSettings& s) + return with_global_settings_object([](const QSettings& s) { const QString old_value = s.value(KEY_NAME).toString(); return old_value.contains(OLD_RECORD_SEPARATOR); @@ -35,7 +36,7 @@ struct process_detector_record_separator : migration void run() override { - return group::with_global_settings_object([](QSettings& s) + return with_global_settings_object([](QSettings& s) { QString value = s.value(KEY_NAME).toString(); value.replace(OLD_UNIT_SEPARATOR, NEW_UNIT_SEPARATOR); diff --git a/migration/migration.cpp b/migration/migration.cpp index 8e5fea5e..386fde9b 100644 --- a/migration/migration.cpp +++ b/migration/migration.cpp @@ -20,6 +20,8 @@ #include <memory> +using namespace options::globals; + // individual migrations are run in the UI thread. they can be interactive if necessary. namespace migrations { @@ -105,7 +107,7 @@ QString migrator::last_migration_time() { QString ret; - options::group::with_settings_object([&](QSettings& s) { + with_settings_object([&](QSettings& s) { s.beginGroup("migrations"); ret = s.value("last-migration-at", "19700101_00").toString(); s.endGroup(); @@ -129,13 +131,13 @@ QString migrator::time_after_migrations() void migrator::set_last_migration_time(const QString& val) { - options::group::with_settings_object([&](QSettings& s) { + 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(); + mark_ini_modified(); } s.endGroup(); }); @@ -155,26 +157,24 @@ std::vector<QString> migrator::run() const QString last_migration = last_migration_time(); - options::group::with_global_settings_object([&](QSettings&) { - options::group::with_settings_object([&](QSettings&) { - for (mptr m : migrations()) + with_global_settings_object([&](QSettings&) { + for (mptr const& m : migrations()) + { + const QString date = m->unique_date(); + + if (date <= last_migration) + continue; + + if (m->should_run()) { - const QString date = m->unique_date(); - - if (date <= last_migration) - continue; - - if (m->should_run()) - { - const QByteArray name = m->name().toUtf8(); - const QByteArray date = m->unique_date().toUtf8(); - qDebug() << "migrate:" << date.constData() << name.constData(); - m->run(); - done.push_back(m->name()); - } + const QByteArray name = m->name().toUtf8(); + const QByteArray date = m->unique_date().toUtf8(); + qDebug() << "migrate:" << date.constData() << name.constData(); + m->run(); + done.push_back(m->name()); } - mark_config_as_not_needing_migration(); - }); + } + mark_config_as_not_needing_migration(); }); return done; |