summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorShawn Hoffman <godisgovernment@gmail.com>2022-06-02 23:32:21 -0700
committerShawn Hoffman <godisgovernment@gmail.com>2022-06-02 23:32:21 -0700
commit27dd2c4aa4dcb63c6fa91e384e1bc82787497234 (patch)
tree37b5d2905cbf627cab4892b7df2f930f1cd8fec4 /Source/Core
parentf7f47d3cd08991915a9fe14070653697d715929d (diff)
qt: unregister Settings' DevicesChanged callback during shutdown
fixes a crash on close
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DolphinQt/MainWindow.cpp2
-rw-r--r--Source/Core/DolphinQt/Settings.cpp7
-rw-r--r--Source/Core/DolphinQt/Settings.h7
3 files changed, 14 insertions, 2 deletions
diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp
index 361a182819..d2dea76787 100644
--- a/Source/Core/DolphinQt/MainWindow.cpp
+++ b/Source/Core/DolphinQt/MainWindow.cpp
@@ -360,6 +360,8 @@ void MainWindow::ShutdownControllers()
{
m_hotkey_scheduler->Stop();
+ Settings::Instance().UnregisterDevicesChangedCallback();
+
Pad::Shutdown();
Pad::ShutdownGBA();
Keyboard::Shutdown();
diff --git a/Source/Core/DolphinQt/Settings.cpp b/Source/Core/DolphinQt/Settings.cpp
index 0ecee648d8..e08e32c0ad 100644
--- a/Source/Core/DolphinQt/Settings.cpp
+++ b/Source/Core/DolphinQt/Settings.cpp
@@ -69,7 +69,7 @@ Settings::Settings()
}
});
- g_controller_interface.RegisterDevicesChangedCallback([this] {
+ m_hotplug_callback_handle = g_controller_interface.RegisterDevicesChangedCallback([this] {
if (Host::GetInstance()->IsHostThread())
{
emit DevicesChanged();
@@ -90,6 +90,11 @@ Settings::Settings()
Settings::~Settings() = default;
+void Settings::UnregisterDevicesChangedCallback()
+{
+ g_controller_interface.UnregisterDevicesChangedCallback(m_hotplug_callback_handle);
+}
+
Settings& Settings::Instance()
{
static Settings settings;
diff --git a/Source/Core/DolphinQt/Settings.h b/Source/Core/DolphinQt/Settings.h
index 1471daddec..335cef9a76 100644
--- a/Source/Core/DolphinQt/Settings.h
+++ b/Source/Core/DolphinQt/Settings.h
@@ -12,6 +12,7 @@
#include "Core/Config/MainSettings.h"
#include "DiscIO/Enums.h"
+#include "InputCommon/ControllerInterface/ControllerInterface.h"
namespace Core
{
@@ -44,6 +45,8 @@ public:
~Settings();
+ void UnregisterDevicesChangedCallback();
+
static Settings& Instance();
static QSettings& GetQSettings();
@@ -199,10 +202,12 @@ signals:
void USBKeyboardConnectionChanged(bool connected);
private:
+ Settings();
+
bool m_batch = false;
std::shared_ptr<NetPlay::NetPlayClient> m_client;
std::shared_ptr<NetPlay::NetPlayServer> m_server;
- Settings();
+ ControllerInterface::HotplugCallbackHandle m_hotplug_callback_handle;
};
Q_DECLARE_METATYPE(Core::State);