mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix race condition when detaching a multiplayer game while running
This commit is contained in:
parent
51e214ce5a
commit
ee3edbbd19
src/platform/qt
|
@ -159,6 +159,9 @@ void MultiplayerController::detachGame(GameController* controller) {
|
||||||
if (!thread) {
|
if (!thread) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < m_players.count(); ++i) {
|
||||||
|
m_players[i].controller->threadInterrupt();
|
||||||
|
}
|
||||||
#ifdef M_CORE_GBA
|
#ifdef M_CORE_GBA
|
||||||
if (controller->platform() == PLATFORM_GBA) {
|
if (controller->platform() == PLATFORM_GBA) {
|
||||||
GBA* gba = static_cast<GBA*>(thread->core->board);
|
GBA* gba = static_cast<GBA*>(thread->core->board);
|
||||||
|
@ -171,12 +174,17 @@ void MultiplayerController::detachGame(GameController* controller) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
controller->threadContinue();
|
||||||
for (int i = 0; i < m_players.count(); ++i) {
|
for (int i = 0; i < m_players.count(); ++i) {
|
||||||
if (m_players[i].controller == controller) {
|
if (m_players[i].controller == controller) {
|
||||||
m_players.removeAt(i);
|
m_players.removeAt(i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (int i = 0; i < m_players.count(); ++i) {
|
||||||
|
m_players[i].controller->threadContinue();
|
||||||
|
}
|
||||||
emit gameDetached();
|
emit gameDetached();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue