Qt: Fix crashing behavior

This commit is contained in:
Jeffrey Pfau 2016-09-04 09:09:24 -07:00
parent a20061e925
commit 51e214ce5a
3 changed files with 9 additions and 2 deletions

View File

@ -249,6 +249,12 @@ bool mCoreThreadHasCrashed(struct mCoreThread* threadContext) {
return hasExited; return hasExited;
} }
void mCoreThreadMarkCrashed(struct mCoreThread* threadContext) {
MutexLock(&threadContext->stateMutex);
threadContext->state = THREAD_CRASHED;
MutexUnlock(&threadContext->stateMutex);
}
void mCoreThreadEnd(struct mCoreThread* threadContext) { void mCoreThreadEnd(struct mCoreThread* threadContext) {
MutexLock(&threadContext->stateMutex); MutexLock(&threadContext->stateMutex);
_waitOnInterrupt(threadContext); _waitOnInterrupt(threadContext);

View File

@ -72,6 +72,7 @@ bool mCoreThreadStart(struct mCoreThread* threadContext);
bool mCoreThreadHasStarted(struct mCoreThread* threadContext); bool mCoreThreadHasStarted(struct mCoreThread* threadContext);
bool mCoreThreadHasExited(struct mCoreThread* threadContext); bool mCoreThreadHasExited(struct mCoreThread* threadContext);
bool mCoreThreadHasCrashed(struct mCoreThread* threadContext); bool mCoreThreadHasCrashed(struct mCoreThread* threadContext);
void mCoreThreadMarkCrashed(struct mCoreThread* threadContext);
void mCoreThreadEnd(struct mCoreThread* threadContext); void mCoreThreadEnd(struct mCoreThread* threadContext);
void mCoreThreadReset(struct mCoreThread* threadContext); void mCoreThreadReset(struct mCoreThread* threadContext);
void mCoreThreadJoin(struct mCoreThread* threadContext); void mCoreThreadJoin(struct mCoreThread* threadContext);

View File

@ -224,6 +224,7 @@ GameController::GameController(QObject* parent)
} }
} }
if (level == mLOG_FATAL) { if (level == mLOG_FATAL) {
mCoreThreadMarkCrashed(controller->thread());
QMetaObject::invokeMethod(controller, "crashGame", Q_ARG(const QString&, QString().vsprintf(format, args))); QMetaObject::invokeMethod(controller, "crashGame", Q_ARG(const QString&, QString().vsprintf(format, args)));
} else if (!(controller->m_logLevels & level)) { } else if (!(controller->m_logLevels & level)) {
return; return;
@ -556,9 +557,8 @@ void GameController::cleanGame() {
} }
void GameController::crashGame(const QString& crashMessage) { void GameController::crashGame(const QString& crashMessage) {
cleanGame(); closeGame();
emit gameCrashed(crashMessage); emit gameCrashed(crashMessage);
emit gameStopped(&m_threadContext);
} }
bool GameController::isPaused() { bool GameController::isPaused() {