diff options
Diffstat (limited to 'opentrack')
-rw-r--r-- | opentrack/options.hpp | 10 | ||||
-rw-r--r-- | opentrack/plugin-support.cpp | 5 |
2 files changed, 9 insertions, 6 deletions
diff --git a/opentrack/options.hpp b/opentrack/options.hpp index 5eae754f..23ce6f7b 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); @@ -258,8 +262,6 @@ namespace options { if (--std::get<0>(implsgl_data[key]) == 0) implsgl_data.erase(key); } - - ~opt_singleton() { implsgl_data.clear(); } }; using pbundle = std::shared_ptr<opt_bundle>; diff --git a/opentrack/plugin-support.cpp b/opentrack/plugin-support.cpp index 2c129906..403798de 100644 --- a/opentrack/plugin-support.cpp +++ b/opentrack/plugin-support.cpp @@ -120,15 +120,16 @@ QList<mem<dylib>> dylib::enum_libraries() dylib::dylib(const QString& filename, Type t) : type(t), + filename(filename), Dialog(nullptr), Constructor(nullptr), - Meta(nullptr) + Meta(nullptr), + handle(nullptr) { // otherwise dlopen opens the calling executable if (filename.size() == 0) return; - this->filename = filename; #if defined(_WIN32) QString fullPath = QCoreApplication::applicationDirPath() + "/" + this->filename; handle = new QLibrary(fullPath); |