summaryrefslogtreecommitdiff
path: root/Source/Core/DolphinQt/MainWindow.cpp
diff options
context:
space:
mode:
authorFiloppi <filippotarpini@hotmail.it>2021-05-21 01:33:38 +0300
committerFiloppi <filippotarpini@hotmail.it>2021-06-07 11:48:30 +0300
commit83ea16f40238fa82981221ba65061a7094b2a64b (patch)
tree5a058d8aa001d2577f7e65d5aa44ec86737c3386 /Source/Core/DolphinQt/MainWindow.cpp
parenta77e3b4a9bc557ac00b63c13abdb4074069e9a7d (diff)
Qt: Fix IOWindow keeping a shared ptr to devices even after them being removed by the ControllerInterface
this prevented some devices from being recreated correctly, as they were exclusive (e.g. DInput Joysticks) This is achieved by calling Settings::ReleaseDevices(), which releases all the UI devices shared ptrs. If we are the host (Qt) thread, DevicesChanged() is now called in line, to avoid devices being hanged onto by the UI. For this, I had to add a method to check whether we are the Host Thread to Qt. Avoid calling ControllerInterface::RefreshDevices() from the CPU thread if the emulation is running and we manually refresh devices from Qt, as that is not necessary anymore. Refactored the way IOWindow lists devices to make it clearer and hold onto disconnected devices. There were so many issues with the previous code: -Devices changes would not be reflected until the window was re-opened -If there was no default device, it would fail to select the device at index 0 -It could have crashed if we had 0 devices -The default device was not highlighted as such
Diffstat (limited to 'Source/Core/DolphinQt/MainWindow.cpp')
-rw-r--r--Source/Core/DolphinQt/MainWindow.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/Source/Core/DolphinQt/MainWindow.cpp b/Source/Core/DolphinQt/MainWindow.cpp
index 3b01fec11b..265155f2b9 100644
--- a/Source/Core/DolphinQt/MainWindow.cpp
+++ b/Source/Core/DolphinQt/MainWindow.cpp
@@ -789,7 +789,7 @@ void MainWindow::TogglePause()
void MainWindow::OnStopComplete()
{
m_stop_requested = false;
- HideRenderWidget();
+ HideRenderWidget(true, m_exit_requested);
#ifdef USE_DISCORD_PRESENCE
if (!m_netplay_dialog->isVisible())
Discord::UpdateDiscordPresence();
@@ -1099,7 +1099,7 @@ void MainWindow::ShowRenderWidget()
}
}
-void MainWindow::HideRenderWidget(bool reinit)
+void MainWindow::HideRenderWidget(bool reinit, bool is_exit)
{
if (m_rendering_to_main)
{
@@ -1136,7 +1136,9 @@ void MainWindow::HideRenderWidget(bool reinit)
// The controller interface will still be registered to the old render widget, if the core
// has booted. Therefore, we should re-bind it to the main window for now. When the core
// is next started, it will be swapped back to the new render widget.
- g_controller_interface.ChangeWindow(GetWindowSystemInfo(windowHandle()).render_window);
+ g_controller_interface.ChangeWindow(GetWindowSystemInfo(windowHandle()).render_window,
+ is_exit ? ControllerInterface::WindowChangeReason::Exit :
+ ControllerInterface::WindowChangeReason::Other);
}
}