From f9b167d8c640b6ab5fa7d5fd4639fa0d34d6603d Mon Sep 17 00:00:00 2001 From: Simonx22 Date: Fri, 7 Nov 2025 22:10:08 -0500 Subject: [PATCH 1/2] DolphinAnalytics: Reload backend when config changes Co-Authored-By: OatmealDome --- Source/Core/Core/DolphinAnalytics.cpp | 7 +++++++ Source/Core/Core/DolphinAnalytics.h | 5 +++++ 2 files changed, 12 insertions(+) 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{}; }; From f67691d5641fac48a6d4e52968195a62f45f7d4d Mon Sep 17 00:00:00 2001 From: Simonx22 Date: Fri, 7 Nov 2025 23:13:35 -0500 Subject: [PATCH 2/2] Config: Use maximum value of size_t instead of -1 as default value in ConfigChangedCallbackID Co-authored-by: OatmealDome --- Source/Core/Common/Config/Config.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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; };