diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2014-10-17 15:56:48 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2014-10-17 16:08:10 +0200 |
commit | df14cc706efe3966713dc0cd5d7951bbbf25e2b7 (patch) | |
tree | fc3bec1dcc0649ce04e02cad599e06919219f955 | |
parent | eb1a95e3cea400340e5a64c2791a4a09ca3a0074 (diff) |
fix options singleton duplicating itself on win32
-rw-r--r-- | facetracknoir/options.h | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/facetracknoir/options.h b/facetracknoir/options.h index d9667e4a..9f14b62a 100644 --- a/facetracknoir/options.h +++ b/facetracknoir/options.h @@ -212,6 +212,12 @@ namespace options { public: opt_singleton() : implsgl_mtx(QMutex::Recursive) {} + static opt_singleton<k, v>& datum() + { + static opt_singleton<k, v> ret; + return ret; + } + pbundle bundle(const k& key) { QMutexLocker l(&implsgl_mtx); @@ -237,20 +243,23 @@ namespace options { using pbundle = std::shared_ptr<opt_bundle>; using t_fact = opt_singleton<string, opt_bundle>; - static t_fact* opt_factory = new t_fact; } - static inline t_fact::pbundle bundle(const string name) { return opt_factory->bundle(name); } + static inline t_fact::pbundle bundle(const string name) { return t_fact::datum().bundle(name); } class opt_bundle : public impl_bundle { public: opt_bundle() : impl_bundle("i-have-no-name") {} - opt_bundle(const string& group_name) : impl_bundle(group_name) {} + opt_bundle(const string& group_name) : impl_bundle(group_name) + { + qDebug() << "bundle +" << QString::fromStdString(group_name); + } ~opt_bundle() { - opt_factory->bundle_decf(this->group_name); + qDebug() << "bundle -" << QString::fromStdString(group_name); + t_fact::datum().bundle_decf(group_name); } }; |