summaryrefslogtreecommitdiffhomepage
path: root/options
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2016-08-21 17:36:22 +0200
committerStanislaw Halik <sthalik@misaki.pl>2016-08-23 00:05:15 +0200
commit6e943c80dabdeb3c43e0a6b635c24defbc31912f (patch)
tree8d4d25eab4ce30fa3619332b336110d6fb849d4e /options
parente3fc3ee8bb4627ace30217b217d02151173059d6 (diff)
options/bundle: treat bundles with empty names specially
They're now not cached in the singleton. Operations like "reload", "save", and connector stuff short-circuit to prevent anything done with them
Diffstat (limited to 'options')
-rw-r--r--options/bundle.cpp20
-rw-r--r--options/bundle.hpp5
-rw-r--r--options/connector.cpp6
3 files changed, 23 insertions, 8 deletions
diff --git a/options/bundle.cpp b/options/bundle.cpp
index a080bb77..83981ddf 100644
--- a/options/bundle.cpp
+++ b/options/bundle.cpp
@@ -19,14 +19,15 @@ bundle::bundle(const QString& group_name)
void bundle::reload()
{
+ if (group_name.size())
{
QMutexLocker l(&mtx);
saved = group(group_name);
transient = saved;
connector::notify_all_values();
+ emit reloading();
}
- emit reloading();
}
void bundle::store_kv(const QString& name, const QVariant& datum)
@@ -35,7 +36,8 @@ void bundle::store_kv(const QString& name, const QVariant& datum)
transient.put(name, datum);
- connector::notify_values(name);
+ if (group_name.size())
+ connector::notify_values(name);
}
bool bundle::contains(const QString &name) const
@@ -46,7 +48,7 @@ bool bundle::contains(const QString &name) const
void bundle::save_deferred(QSettings& s)
{
- if (group_name == "")
+ if (group_name.size() == 0)
return;
bool modified_ = false;
@@ -146,7 +148,17 @@ OPENTRACK_OPTIONS_EXPORT bundler& singleton()
return ret;
}
-} // end options::detail
+}
+
+// end options::detail
+
+OPENTRACK_OPTIONS_EXPORT bundle make_bundle(const QString& name)
+{
+ if (name.size())
+ return detail::singleton().make_bundle(name);
+ else
+ return std::make_shared<bundle_type>(QStringLiteral(""));
+}
} // end options
diff --git a/options/bundle.hpp b/options/bundle.hpp
index 841df273..a948ac44 100644
--- a/options/bundle.hpp
+++ b/options/bundle.hpp
@@ -84,9 +84,6 @@ OPENTRACK_OPTIONS_EXPORT bundler& singleton();
using bundle_type = detail::bundle;
using bundle = std::shared_ptr<bundle_type>;
-inline bundle make_bundle(const QString& name)
-{
- return detail::singleton().make_bundle(name);
-}
+OPENTRACK_OPTIONS_EXPORT bundle make_bundle(const QString& name);
}
diff --git a/options/connector.cpp b/options/connector.cpp
index c1bbce39..680283cf 100644
--- a/options/connector.cpp
+++ b/options/connector.cpp
@@ -36,6 +36,9 @@ bool connector::on_value_destructed_impl(const QString& name, const base_value*
void connector::on_value_destructed(const QString& name, const base_value* val)
{
+ if (!name.size())
+ return;
+
const bool ok = on_value_destructed_impl(name, val);
if (!ok)
@@ -48,6 +51,9 @@ void connector::on_value_destructed(const QString& name, const base_value* val)
void connector::on_value_created(const QString& name, const base_value* val)
{
+ if (!name.size())
+ return;
+
QMutexLocker l(get_mtx());
if (on_value_destructed_impl(name, val))