From 092e2910ae8f6c2e188e930b9540d58e145c9142 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 20 Oct 2017 17:13:03 +0200 Subject: options: allow for dud values --- options/value.hpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'options') diff --git a/options/value.hpp b/options/value.hpp index e8c39445..099a8cb2 100644 --- a/options/value.hpp +++ b/options/value.hpp @@ -45,6 +45,9 @@ class value final : public base_value never_inline t get() const { + if (self_name.isEmpty()) + return def; + if (!b->contains(self_name) || b->get(self_name).type() == QVariant::Invalid) return def; @@ -57,8 +60,12 @@ public: never_inline t operator=(const t& datum) { + if (self_name.isEmpty()) + return def; + if (datum != get()) store(traits::to_storage(datum)); + return datum; } @@ -104,13 +111,15 @@ public: never_inline void reload() override { - *this = static_cast(*this); + if (!self_name.isEmpty()) + *this = static_cast(*this); } never_inline void bundle_value_changed() const override { - emit valueChanged(traits::to_storage(get())); + if (!self_name.isEmpty()) + emit valueChanged(traits::to_storage(get())); } never_inline -- cgit v1.2.3