summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorOatmealDome <OatmealDome@users.noreply.github.com>2025-11-08 14:00:03 -0500
committerGitHub <noreply@github.com>2025-11-08 14:00:03 -0500
commita459dc0d250b458a3d0eb152bb17e3ce0f5974e6 (patch)
tree0b0436e05fe5a51337f7d85237432f15ebd015e1 /Source
parent958db7c78c33ce16be693910e30cbd128079caa9 (diff)
parentf67691d5641fac48a6d4e52968195a62f45f7d4d (diff)
Merge pull request #14082 from Simonx22/analytics/reload-on-setting-change
DolphinAnalytics: Reload backend when config changes
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Common/Config/Config.h3
-rw-r--r--Source/Core/Core/DolphinAnalytics.cpp7
-rw-r--r--Source/Core/Core/DolphinAnalytics.h5
3 files changed, 14 insertions, 1 deletions
diff --git a/Source/Core/Common/Config/Config.h b/Source/Core/Common/Config/Config.h
index e3e3d3df3b..1e0b32551b 100644
--- a/Source/Core/Common/Config/Config.h
+++ b/Source/Core/Common/Config/Config.h
@@ -4,6 +4,7 @@
#pragma once
#include <functional>
+#include <limits>
#include <map>
#include <memory>
#include <optional>
@@ -17,7 +18,7 @@ namespace Config
{
struct ConfigChangedCallbackID
{
- size_t id = -1;
+ size_t id = std::numeric_limits<size_t>::max();
bool operator==(const ConfigChangedCallbackID&) const = default;
};
diff --git a/Source/Core/Core/DolphinAnalytics.cpp b/Source/Core/Core/DolphinAnalytics.cpp
index 2d6b78429c..e6633d9a6b 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 fd468bd019..b4ff4877df 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 <functional>
@@ -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{};
};