diff --git a/Source/Core/Common/Config/Config.h b/Source/Core/Common/Config/Config.h index e3e3d3df3b5..1e0b32551b1 100644 --- a/Source/Core/Common/Config/Config.h +++ b/Source/Core/Common/Config/Config.h @@ -4,6 +4,7 @@ #pragma once #include +#include #include #include #include @@ -17,7 +18,7 @@ namespace Config { struct ConfigChangedCallbackID { - size_t id = -1; + size_t id = std::numeric_limits::max(); bool operator==(const ConfigChangedCallbackID&) const = default; }; diff --git a/Source/Core/Core/DolphinAnalytics.cpp b/Source/Core/Core/DolphinAnalytics.cpp index 2d6b78429cd..e6633d9a6bc 100644 --- a/Source/Core/Core/DolphinAnalytics.cpp +++ b/Source/Core/Core/DolphinAnalytics.cpp @@ -58,6 +58,13 @@ DolphinAnalytics::DolphinAnalytics() { ReloadConfig(); MakeBaseBuilder(); + + m_config_changed_callback_id = Config::AddConfigChangedCallback([this] { ReloadConfig(); }); +} + +DolphinAnalytics::~DolphinAnalytics() +{ + Config::RemoveConfigChangedCallback(m_config_changed_callback_id); } DolphinAnalytics& DolphinAnalytics::Instance() diff --git a/Source/Core/Core/DolphinAnalytics.h b/Source/Core/Core/DolphinAnalytics.h index fd468bd0196..b4ff4877df9 100644 --- a/Source/Core/Core/DolphinAnalytics.h +++ b/Source/Core/Core/DolphinAnalytics.h @@ -11,6 +11,7 @@ #include "Common/Analytics.h" #include "Common/CommonTypes.h" +#include "Common/Config/Config.h" #if defined(ANDROID) #include @@ -108,6 +109,9 @@ class DolphinAnalytics public: // Performs lazy-initialization of a singleton and returns the instance. static DolphinAnalytics& Instance(); + DolphinAnalytics(const DolphinAnalytics&) = delete; + DolphinAnalytics& operator=(const DolphinAnalytics&) = delete; + ~DolphinAnalytics(); #if defined(ANDROID) // Get value from java. @@ -198,4 +202,5 @@ private: std::mutex m_reporter_mutex; Common::AnalyticsReporter m_reporter; + Config::ConfigChangedCallbackID m_config_changed_callback_id{}; };