@@ -817,11 +817,15 @@ - (void) emulatorDidInitialize: (NSNotification *)notification
817817
818818- (void ) emulatorDidFinish : (NSNotification *)notification
819819{
820+ // If we were fast-forwarding, clear the bezel now.
821+ [self releaseFastForward: self ];
822+
820823 // Flag that we're no longer emulating
821824 self.emulating = NO ;
825+
822826 // Turn off display-sleep suppression
823827 [self _syncSuppressesDisplaySleep ];
824-
828+
825829 // Clear our program caches
826830 self.lastExecutedProgramPath = nil ;
827831 self.lastLaunchedProgramPath = nil ;
@@ -1008,14 +1012,16 @@ - (void) emulatorDidFinishProgram: (NSNotification *)notification
10081012 // Clear the last executed program when a startup program or 'non-defaultable'
10091013 // program finishes. This way, programWillStart: won't hang onto programs
10101014 // we can't use as the default, such as autoexec commands or dispatch batchfiles.
1011- // (Note that the last executed program is always cleared down in didReturnToShell:)
1015+
1016+ // Note that we don't clear lastLaunchedProgramPath here, since the program may be
1017+ // passing control on to another program afterwards and we want to maintain a record
1018+ // of which program the user themselves actually launched. Both the last executed
1019+ // and the last launched program are always cleared down in didReturnToShell:.
10121020 NSString *executedPath = self.lastExecutedProgramPath ;
10131021 BOOL executedPathCanBeDefault = (executedPath && _hasLaunched && [self .gamePackage validateTargetPath: &executedPath error: nil ]);
10141022 if (!executedPathCanBeDefault)
10151023 {
10161024 self.lastExecutedProgramPath = nil ;
1017- // TODO: do we need to extend this to lastLaunchedProgramPath too?
1018- // The logic here is pretty damn fuzzy.
10191025 }
10201026
10211027 // Check the running time of the program. If it was suspiciously short,
@@ -1224,8 +1230,8 @@ - (BOOL) _shouldCloseOnProgramExit
12241230 // Don't close if the auto-close preference is disabled for this gamebox
12251231 if (!self.gamePackage .closeOnExit ) return NO ;
12261232
1227- // Don't close if we've been running a program other than the default program for the gamebox
1228- if (![self .activeProgramPath isEqualToString: self .gamePackage.targetPath]) return NO ;
1233+ // Don't close if we launched a program other than the default program for the gamebox
1234+ if (![self .lastLaunchedProgramPath isEqualToString: self .gamePackage.targetPath]) return NO ;
12291235
12301236 // Don't close if there are drive imports in progress
12311237 if (self.isImportingDrives ) return NO ;
0 commit comments