summaryrefslogtreecommitdiffhomepage
path: root/facetracknoir/options.h
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-09-23 02:11:45 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-09-23 02:11:45 +0200
commitc678574f6fd84ede6744a1fcc4453cd67d8a60da (patch)
tree89ad38d3e734b95c3c1e46111e6cc6d9a1a8da22 /facetracknoir/options.h
parent460eb42ae913700903df7b25d50282397da95395 (diff)
options: fix cookie logic
Diffstat (limited to 'facetracknoir/options.h')
-rw-r--r--facetracknoir/options.h14
1 files 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<QVariant>(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<T>(def));
}
}
- operator T() { return b->get<T>(self_name); }
+ operator T()
+ {
+ maybe_lazy_change();
+ return b->get<T>(self_name);
+ }
QVariant operator=(const T& datum)
{
return this->operator =(qVariantFromValue<T>(datum));