From 078059915bdb39726924ef5bfed159c8dcf2af6c Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 9 Sep 2016 15:18:26 +0200 Subject: options/{bundle,group}: don't create QSettings all the time --- options/bundle.cpp | 8 +++++--- options/bundle.hpp | 2 +- options/group.cpp | 7 +++++-- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'options') 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 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 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 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 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()); -- cgit v1.2.3