From df14cc706efe3966713dc0cd5d7951bbbf25e2b7 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 17 Oct 2014 15:56:48 +0200 Subject: fix options singleton duplicating itself on win32 --- facetracknoir/options.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'facetracknoir/options.h') 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& datum() + { + static opt_singleton ret; + return ret; + } + pbundle bundle(const k& key) { QMutexLocker l(&implsgl_mtx); @@ -237,20 +243,23 @@ namespace options { using pbundle = std::shared_ptr; using t_fact = opt_singleton; - 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); } }; -- cgit v1.2.3