summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorJosJuice <josjuice@gmail.com>2021-06-11 18:59:39 +0200
committerGitHub <noreply@github.com>2021-06-11 18:59:39 +0200
commita09d9cf608fa9d2c20f6419879ad9867e1990cea (patch)
tree512e14d048dbefbd0ba0a8e9c221d0ea7772e13f /Source/Core
parent0c6e00ce0c8da1d81094bb41fea2eafe6b279891 (diff)
parente6057c5f62ed43d445416517913f44f06673d44e (diff)
Merge pull request #9606 from Filoppi/patch-14
Qt: avoid queuing ConfigChanged() more than once
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DolphinQt/Settings.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/Source/Core/DolphinQt/Settings.cpp b/Source/Core/DolphinQt/Settings.cpp
index 3f9fb663f0..26f5679a8c 100644
--- a/Source/Core/DolphinQt/Settings.cpp
+++ b/Source/Core/DolphinQt/Settings.cpp
@@ -4,6 +4,8 @@
#include "DolphinQt/Settings.h"
+#include <atomic>
+
#include <QApplication>
#include <QDir>
#include <QFile>
@@ -42,8 +44,21 @@ Settings::Settings()
QueueOnObject(this, [this, new_state] { emit EmulationStateChanged(new_state); });
});
- Config::AddConfigChangedCallback(
- [this] { QueueOnObject(this, [this] { emit ConfigChanged(); }); });
+ Config::AddConfigChangedCallback([this] {
+ static std::atomic<bool> do_once{true};
+ if (do_once.exchange(false))
+ {
+ // Calling ConfigChanged() with a "delay" can have risks, for example, if from
+ // code we change some configs that result in Qt greying out some setting, we could
+ // end up editing that setting before its greyed out, sending out an event,
+ // which might not be expected or handled by the code, potentially crashing.
+ // The only safe option would be to wait on the Qt thread to have finished executing this.
+ QueueOnObject(this, [this] {
+ do_once = true;
+ emit ConfigChanged();
+ });
+ }
+ });
g_controller_interface.RegisterDevicesChangedCallback([this] {
if (Host::GetInstance()->IsHostThread())