From c678574f6fd84ede6744a1fcc4453cd67d8a60da Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 23 Sep 2014 02:11:45 +0200 Subject: options: fix cookie logic --- facetracknoir/options.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/facetracknoir/options.h b/facetracknoir/options.h index d751051a..0e275c77 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -179,14 +179,12 @@ namespace options { class base_value : public QObject { Q_OBJECT public: - base_value(pbundle b, const QString& name) : b(b), self_name(name), cookie_snap(b->cookie()) {} + base_value(pbundle b, const QString& name) : b(b), self_name(name), cookie_snap(0) {} protected: virtual QVariant operator=(const QVariant& datum) = 0; pbundle b; QString self_name; - private: - long cookie_snap; - void reread_value() + void maybe_lazy_change() { long cookie = b->cookie(); if (cookie_snap != cookie) @@ -195,6 +193,8 @@ namespace options { this->operator=(b->get(self_name)); } } + private: + long cookie_snap; public slots: #define DEFINE_SLOT(t) void setValue(t datum) { this->operator=(qVariantFromValue(datum)); } DEFINE_SLOT(double) @@ -229,7 +229,11 @@ namespace options { this->operator=(qVariantFromValue(def)); } } - operator T() { return b->get(self_name); } + operator T() + { + maybe_lazy_change(); + return b->get(self_name); + } QVariant operator=(const T& datum) { return this->operator =(qVariantFromValue(datum)); -- cgit v1.2.3