From 09e4400f3cfc7654181a76264203f0c6c5d9315a Mon Sep 17 00:00:00 2001 From: Arisotura Date: Fri, 1 Nov 2024 00:40:09 +0100 Subject: [PATCH] fix hang when closing an instance that is engaged into local multiplayer --- src/frontend/qt_sdl/EmuInstance.cpp | 2 -- src/frontend/qt_sdl/EmuThread.cpp | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/frontend/qt_sdl/EmuInstance.cpp b/src/frontend/qt_sdl/EmuInstance.cpp index f4092b61..89d4108b 100644 --- a/src/frontend/qt_sdl/EmuInstance.cpp +++ b/src/frontend/qt_sdl/EmuInstance.cpp @@ -154,8 +154,6 @@ EmuInstance::~EmuInstance() deleting = true; deleteAllWindows(); - MPInterface::Get().End(instanceID); - emuThread->emuExit(); emuThread->wait(); delete emuThread; diff --git a/src/frontend/qt_sdl/EmuThread.cpp b/src/frontend/qt_sdl/EmuThread.cpp index 6417fa69..f767c6db 100644 --- a/src/frontend/qt_sdl/EmuThread.cpp +++ b/src/frontend/qt_sdl/EmuThread.cpp @@ -478,7 +478,8 @@ void EmuThread::waitMessage(int num) void EmuThread::waitAllMessages() { if (QThread::currentThread() == this) return; - msgSemaphore.acquire(msgSemaphore.available()); + while (!msgQueue.empty()) + msgSemaphore.acquire(); } void EmuThread::handleMessages() @@ -494,6 +495,7 @@ void EmuThread::handleMessages() emuPauseStack = emuPauseStackRunning; emuInstance->audioDisable(); + MPInterface::Get().End(emuInstance->instanceID); break; case msg_EmuRun: