diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-09-09 15:18:26 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-09-09 18:33:30 +0200 |
commit | 078059915bdb39726924ef5bfed159c8dcf2af6c (patch) | |
tree | 4772c907c2a4e0c4ab2df0b3b4464e1f848902c9 /options | |
parent | 96687dbf37b2aa2fc05a85a312ab573e64923879 (diff) |
options/{bundle,group}: don't create QSettings all the time
Diffstat (limited to 'options')
-rw-r--r-- | options/bundle.cpp | 8 | ||||
-rw-r--r-- | options/bundle.hpp | 2 | ||||
-rw-r--r-- | options/group.cpp | 7 |
3 files changed, 11 insertions, 6 deletions
diff --git a/options/bundle.cpp b/options/bundle.cpp index 61be509a..876599ce 100644 --- a/options/bundle.cpp +++ b/options/bundle.cpp @@ -20,12 +20,12 @@ bundle::~bundle() { } -void bundle::reload() +void bundle::reload(std::shared_ptr<QSettings> settings) { if (group_name.size()) { QMutexLocker l(&mtx); - saved = group(group_name); + saved = group(group_name, settings); const bool has_changes = is_modified(false); transient = saved; @@ -128,6 +128,8 @@ void bundler::after_profile_changed_() { QMutexLocker l(&implsgl_mtx); + std::shared_ptr<QSettings> s = group::ini_file(); + for (auto& kv : implsgl_data) { tt& tuple = kv.second; @@ -137,7 +139,7 @@ void bundler::after_profile_changed_() if (bundle_) { //qDebug() << "bundle: reverting" << kv.first << "due to profile change"; - bundle_->reload(); + bundle_->reload(s); } } } diff --git a/options/bundle.hpp b/options/bundle.hpp index 3d75a8de..b1c93b3d 100644 --- a/options/bundle.hpp +++ b/options/bundle.hpp @@ -56,7 +56,7 @@ public: bundle(const QString& group_name); ~bundle() override; QString name() { return group_name; } - void reload(); + void reload(std::shared_ptr<QSettings> settings = group::ini_file()); void store_kv(const QString& name, const QVariant& datum); bool contains(const QString& name) const; void save(); diff --git a/options/group.cpp b/options/group.cpp index 69b79cef..94e111aa 100644 --- a/options/group.cpp +++ b/options/group.cpp @@ -6,12 +6,11 @@ namespace options { -group::group(const QString& name) : name(name) +group::group(const QString& name, std::shared_ptr<QSettings> conf) : name(name) { if (name == "") return; - auto conf = ini_file(); conf->beginGroup(name); for (auto& k_ : conf->childKeys()) { @@ -22,6 +21,10 @@ group::group(const QString& name) : name(name) conf->endGroup(); } +group::group(const QString& name) : group(name, ini_file()) +{ +} + void group::save() const { save_deferred(*ini_file()); |