diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2015-05-04 11:58:19 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2015-05-04 11:58:19 +0200 |
commit | b4830a840540766909bcd359fe94d5ea5afef81e (patch) | |
tree | ddd7477c09c90cb96d9b812d29d2047f30dc09b6 /opentrack | |
parent | 9ec8acf38a6c09d1d7239146fc115bcef938a64d (diff) |
options: use weak pointers for bundles
Otherwise none ever get freed. Oops!
Diffstat (limited to 'opentrack')
-rw-r--r-- | opentrack/options.hpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/opentrack/options.hpp b/opentrack/options.hpp index 5eae754f..35b1640e 100644 --- a/opentrack/options.hpp +++ b/opentrack/options.hpp @@ -224,7 +224,7 @@ namespace options { { public: using pbundle = std::shared_ptr<v>; - using tt = std::tuple<cnt, pbundle>; + using tt = std::tuple<cnt, std::weak_ptr<v>>; private: QMutex implsgl_mtx; map<k, tt> implsgl_data; @@ -242,7 +242,11 @@ namespace options { QMutexLocker l(&implsgl_mtx); if (implsgl_data.count(key) != 0) - return std::get<1>(implsgl_data[key]); + { + auto shared = std::get<1>(implsgl_data[key]).lock(); + if (shared != nullptr) + return shared; + } qDebug() << "bundle +" << QString::fromStdString(key); |