diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2019-01-16 06:11:48 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2019-01-16 07:49:13 +0100 |
commit | 07b45ca4578ccaed91f7f3c70e82dc7ffbdf47ab (patch) | |
tree | 0904b728158414937919f62714358725f52e7400 /options/value.hpp | |
parent | 1e04979c3452d4eac633677876a88f9411a1153d (diff) |
spline: fix deadlock, logic error
Tracking rarely deadlocked when saving mappings.
Investigating it further also shown how a wrong bundle was used for
Accela's splines.
Diffstat (limited to 'options/value.hpp')
-rw-r--r-- | options/value.hpp | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/options/value.hpp b/options/value.hpp index 64234ecf..b73b519a 100644 --- a/options/value.hpp +++ b/options/value.hpp @@ -46,7 +46,7 @@ class value final : public value_ cc_noinline t get() const noexcept { - if (self_name.isEmpty() || !b->contains(self_name)) + if (!b->contains(self_name)) return traits::pass_value(def); QVariant variant = b->get_variant(self_name); @@ -58,11 +58,8 @@ class value final : public value_ } cc_noinline - void store_variant(const QVariant& value) noexcept override + void store_variant(QVariant&& value) noexcept override { - if (self_name.isEmpty()) - return; - if (traits::is_equal(get(), traits::value_from_qvariant(value))) return; @@ -72,10 +69,30 @@ class value final : public value_ b->store_kv(self_name, traits::qvariant_from_value(def)); } + cc_noinline + void store_variant(const QVariant& value) noexcept override + { + QVariant copy{value}; + store_variant(std::move(copy)); + } + + bool is_null() const + { + return self_name.isEmpty() || b->name().isEmpty(); + } + public: + QVariant get_variant() const noexcept override + { + if (QVariant ret{b->get_variant(self_name)}; ret.isValid() && !ret.isNull()) + return ret; + + return traits::qvariant_from_value(def); + } + void notify() const override { - if (!self_name.isEmpty()) + if (!is_null()) emit valueChanged(traits::storage_from_value(get())); } @@ -100,7 +117,7 @@ public: return def; } - void set_to_default() override + void set_to_default() noexcept override { *this = def; } |