Minor order of execution changes to Qt GUI application quit to prevent crash on MacOS.

This commit is contained in:
mjbudd77 2021-12-23 23:27:46 -05:00
parent d757f972bf
commit b05e210982
1 changed files with 23 additions and 13 deletions

View File

@ -291,17 +291,19 @@ consoleWin_t::~consoleWin_t(void)
closeGamePadConfWindow(); closeGamePadConfWindow();
//printf("Thread Finished: %i \n", gameThread->isFinished() ); // The closeApp function call stops all threads.
emulatorThread->quit(); // Calling quit on threads should not happen here.
emulatorThread->wait( 1000 ); //printf("Thread Finished: %i \n", emulatorThread->isFinished() );
//emulatorThread->quit();
//emulatorThread->wait( 1000 );
aviDiskThread->requestInterruption(); //aviDiskThread->requestInterruption();
aviDiskThread->quit(); //aviDiskThread->quit();
aviDiskThread->wait( 10000 ); //aviDiskThread->wait( 10000 );
fceuWrapperLock(); //fceuWrapperLock();
fceuWrapperClose(); //fceuWrapperClose();
fceuWrapperUnLock(); //fceuWrapperUnLock();
if ( viewport_GL != NULL ) if ( viewport_GL != NULL )
{ {
@ -315,8 +317,8 @@ consoleWin_t::~consoleWin_t(void)
// LoadGame() checks for an IP and if it finds one begins a network session // LoadGame() checks for an IP and if it finds one begins a network session
// clear the NetworkIP field so this doesn't happen unintentionally // clear the NetworkIP field so this doesn't happen unintentionally
g_config->setOption ("SDL.NetworkIP", ""); //g_config->setOption ("SDL.NetworkIP", "");
g_config->save (); //g_config->save ();
// Clear Clipboard Contents on Program Exit // Clear Clipboard Contents on Program Exit
clipboard = QGuiApplication::clipboard(); clipboard = QGuiApplication::clipboard();
@ -2100,9 +2102,17 @@ void consoleWin_t::closeApp(void)
{ {
nes_shm->runEmulator = 0; nes_shm->runEmulator = 0;
gameTimer->stop();
closeGamePadConfWindow();
emulatorThread->quit(); emulatorThread->quit();
emulatorThread->wait( 1000 ); emulatorThread->wait( 1000 );
aviDiskThread->requestInterruption();
aviDiskThread->quit();
aviDiskThread->wait( 10000 );
fceuWrapperLock(); fceuWrapperLock();
fceuWrapperClose(); fceuWrapperClose();
fceuWrapperUnLock(); fceuWrapperUnLock();
@ -2112,8 +2122,8 @@ void consoleWin_t::closeApp(void)
g_config->setOption ("SDL.NetworkIP", ""); g_config->setOption ("SDL.NetworkIP", "");
g_config->save (); g_config->save ();
//qApp::quit(); // Delay Application Quit to allow event processing to complete
qApp->quit(); QTimer::singleShot( 250, qApp, SLOT(quit(void)) );
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void consoleWin_t::videoBgColorChanged( QColor &c ) void consoleWin_t::videoBgColorChanged( QColor &c )