Mac: fix a crash caused by a race condition when switching ROMs

This commit is contained in:
Michael Buckley 2020-01-05 15:50:17 -08:00
parent 89f480207d
commit c12415f351
2 changed files with 21 additions and 49 deletions

View File

@ -102,8 +102,7 @@ int macFastForwardRate = 5,
unsigned long spcFileCount = 0,
pngFileCount = 0;
bool8 finished = false,
cartOpen = false,
bool8 cartOpen = false,
autofire = false;
bool8 fullscreen = false,
@ -2992,8 +2991,6 @@ void QuitWithFatalError ( NSString *message)
- (void)start
{
if (!finished)
{
#ifdef DEBUGGER
CPU.Flags |= DEBUG_MODE_FLAG;
S9xDoDebug();
@ -3011,37 +3008,7 @@ void QuitWithFatalError ( NSString *message)
[NSThread detachNewThreadWithBlock:^
{
MacSnes9xThread(NULL);
dispatch_sync(dispatch_get_main_queue(), ^
{
if (!Settings.NetPlay || Settings.NetPlayServer)
{
SNES9X_SaveSRAM();
S9xResetSaveTimer(false);
S9xSaveCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
}
S9xDeinitDisplay();
if (Settings.NetPlay)
{
if (!Settings.NetPlayServer)
{
// DeinitGameWindow();
cartOpen = false;
}
Settings.NetPlay = false;
Settings.NetPlayServer = false;
}
if (!finished)
{
[self start];
}
});
}];
}
}
- (void)stop
@ -3183,6 +3150,13 @@ void QuitWithFatalError ( NSString *message)
- (BOOL)loadROM:(NSURL *)fileURL
{
running = false;
while (!Settings.StopEmulation)
{
usleep(Settings.FrameTime);
}
if ( SNES9X_OpenCart(fileURL) )
{
SNES9X_Go();

View File

@ -431,8 +431,6 @@ void SNES9X_Quit (void)
S9xResetSaveTimer(false);
S9xSaveCheatFile(S9xGetFilename(".cht", CHEAT_DIR));
}
finished = true;
}
void SNES9X_InitSound (void)