diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2016-08-15 15:30:53 +0200 | 
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-08-16 00:03:40 +0200 | 
| commit | 7f840a7bfd4d89c2f31464922beee9331de81a08 (patch) | |
| tree | b21ace6bf6a193a5114a8c04d39e4643b55683f9 /compat | |
| parent | 558491c9ee7262b4f84e192b0627194a39e884dc (diff) | |
compat/options: add option to reload all bundles
Diffstat (limited to 'compat')
| -rw-r--r-- | compat/options.cpp | 23 | ||||
| -rw-r--r-- | compat/options.hpp | 2 | 
2 files changed, 25 insertions, 0 deletions
diff --git a/compat/options.cpp b/compat/options.cpp index 8c6e6c65..9ff696ac 100644 --- a/compat/options.cpp +++ b/compat/options.cpp @@ -204,6 +204,29 @@ void opt_singleton::bundle_decf(const opt_singleton::k& key)      }  } +void opt_singleton::after_profile_changed_() +{ +    QMutexLocker l(&implsgl_mtx); + +    for (auto& kv : implsgl_data) +    { +        tt& tuple = kv.second; +        std::weak_ptr<v>& bundle = std::get<1>(tuple); + +        mem<v> bundle_ = bundle.lock(); +        if (bundle_) +        { +            qDebug() << "bundle: reverting" << kv.first << "due to profile change"; +            bundle_->reload(); +        } +    } +} + +void opt_singleton::refresh_all_bundles() +{ +    singleton().after_profile_changed_(); +} +  opt_singleton::opt_singleton() : implsgl_mtx(QMutex::Recursive)  {  } diff --git a/compat/options.hpp b/compat/options.hpp index 40aca2de..432ed52a 100644 --- a/compat/options.hpp +++ b/compat/options.hpp @@ -139,10 +139,12 @@ namespace options {          private:              QMutex implsgl_mtx;              map<k, tt> implsgl_data; +            void after_profile_changed_();          public:              opt_singleton();              pbundle bundle(const k& key);              void bundle_decf(const k& key); +            static void refresh_all_bundles();          };          OPENTRACK_COMPAT_EXPORT opt_singleton& singleton();  | 
