Qt: Clean up games in cleanCallback

This commit is contained in:
Jeffrey Pfau 2016-10-27 10:19:10 -07:00
parent ecba499b95
commit 5406130432
1 changed files with 9 additions and 7 deletions

View File

@ -169,6 +169,15 @@ GameController::GameController(QObject* parent)
m_threadContext.cleanCallback = [](mCoreThread* context) {
GameController* controller = static_cast<GameController*>(context->userData);
if (controller->m_multiplayer) {
controller->m_multiplayer->detachGame(controller);
}
controller->m_patch = QString();
controller->clearOverride();
QMetaObject::invokeMethod(controller->m_audioProcessor, "pause", Qt::BlockingQueuedConnection);
QMetaObject::invokeMethod(controller, "gameStopped", Q_ARG(mCoreThread*, context));
QMetaObject::invokeMethod(controller, "cleanGame");
};
@ -589,17 +598,10 @@ void GameController::closeGame() {
if (!m_gameOpen) {
return;
}
if (m_multiplayer) {
m_multiplayer->detachGame(this);
}
if (mCoreThreadIsPaused(&m_threadContext)) {
mCoreThreadUnpause(&m_threadContext);
}
m_patch = QString();
clearOverride();
QMetaObject::invokeMethod(m_audioProcessor, "pause", Qt::BlockingQueuedConnection);
mCoreThreadEnd(&m_threadContext);
}