From 6bc3fe31a3f354afc7be870a4a2d375ab6c746b6 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 9 Sep 2016 08:51:25 +0200 Subject: add support for migrations They're run from the UI thread so can even be interactive. --- options/bundle.cpp | 10 +++++++--- options/bundle.hpp | 6 +++++- options/group.cpp | 4 ++-- options/group.hpp | 5 +++-- 4 files changed, 17 insertions(+), 8 deletions(-) (limited to 'options') diff --git a/options/bundle.cpp b/options/bundle.cpp index 48689720..61be509a 100644 --- a/options/bundle.cpp +++ b/options/bundle.cpp @@ -16,6 +16,10 @@ bundle::bundle(const QString& group_name) { } +bundle::~bundle() +{ +} + void bundle::reload() { if (group_name.size()) @@ -114,7 +118,7 @@ void bundler::bundle_decf(const bundler::k& key) if (--std::get<0>(implsgl_data[key]) == 0) { - qDebug() << "bundle -" << key; + //qDebug() << "bundle -" << key; implsgl_data.erase(key); } @@ -132,7 +136,7 @@ void bundler::after_profile_changed_() mem bundle_ = bundle.lock(); if (bundle_) { - qDebug() << "bundle: reverting" << kv.first << "due to profile change"; + //qDebug() << "bundle: reverting" << kv.first << "due to profile change"; bundle_->reload(); } } @@ -163,7 +167,7 @@ std::shared_ptr bundler::make_bundle(const bundler::k &key) return shared; } - qDebug() << "bundle +" << key; + //qDebug() << "bundle +" << key; std::shared_ptr shr(new v(key), [this](v* val) { bundle_decf(val->name()); }); diff --git a/options/bundle.hpp b/options/bundle.hpp index 20ec9eaa..3d75a8de 100644 --- a/options/bundle.hpp +++ b/options/bundle.hpp @@ -24,6 +24,8 @@ namespace options { namespace detail { +struct bundler; + class OPENTRACK_OPTIONS_EXPORT bundle final : public QObject, public virtual connector { class OPENTRACK_OPTIONS_EXPORT mutex final : public QMutex @@ -35,6 +37,8 @@ class OPENTRACK_OPTIONS_EXPORT bundle final : public QObject, public virtual con Q_OBJECT private: + friend bundler; + mutex mtx; const QString group_name; group saved; @@ -50,7 +54,7 @@ signals: void changed() const; public: bundle(const QString& group_name); - ~bundle() override {} + ~bundle() override; QString name() { return group_name; } void reload(); void store_kv(const QString& name, const QVariant& datum); diff --git a/options/group.cpp b/options/group.cpp index a2169ae5..69b79cef 100644 --- a/options/group.cpp +++ b/options/group.cpp @@ -72,7 +72,7 @@ QString group::ini_pathname() return dir + "/" + ini_filename(); } -const QStringList group::ini_list() +QStringList group::ini_list() { const auto dirname = ini_directory(); if (dirname == "") @@ -83,7 +83,7 @@ const QStringList group::ini_list() return list; } -const std::shared_ptr group::ini_file() +std::shared_ptr group::ini_file() { const auto pathname = ini_pathname(); if (pathname != "") diff --git a/options/group.hpp b/options/group.hpp index f76978ad..f5b3e523 100644 --- a/options/group.hpp +++ b/options/group.hpp @@ -17,6 +17,7 @@ class OPENTRACK_OPTIONS_EXPORT group final QString name; public: std::map kvs; + group(const QString& name, mem s); group(const QString& name); void save() const; void save_deferred(QSettings& s) const; @@ -25,8 +26,8 @@ public: static QString ini_directory(); static QString ini_filename(); static QString ini_pathname(); - static const QStringList ini_list(); - static const std::shared_ptr ini_file(); + static QStringList ini_list(); + static std::shared_ptr ini_file(); template t get(const QString& k) const -- cgit v1.2.3