all repos — mgba @ ee3edbbd19a9bff0b7e3428dd0c09ca37b452291

mGBA Game Boy Advance Emulator

Qt: Fix race condition when detaching a multiplayer game while running
Jeffrey Pfau jeffrey@endrift.com
Sun, 04 Sep 2016 09:31:14 -0700
commit

ee3edbbd19a9bff0b7e3428dd0c09ca37b452291

parent

51e214ce5ad644d88ffbe80a6b6c51b513bc7efb

1 files changed, 8 insertions(+), 0 deletions(-)

jump to
M src/platform/qt/MultiplayerController.cppsrc/platform/qt/MultiplayerController.cpp

@@ -159,6 +159,9 @@ mCoreThread* thread = controller->thread();

if (!thread) { return; } + for (int i = 0; i < m_players.count(); ++i) { + m_players[i].controller->threadInterrupt(); + } #ifdef M_CORE_GBA if (controller->platform() == PLATFORM_GBA) { GBA* gba = static_cast<GBA*>(thread->core->board);

@@ -171,11 +174,16 @@ delete node;

} } #endif + + controller->threadContinue(); for (int i = 0; i < m_players.count(); ++i) { if (m_players[i].controller == controller) { m_players.removeAt(i); break; } + } + for (int i = 0; i < m_players.count(); ++i) { + m_players[i].controller->threadContinue(); } emit gameDetached(); }