Skip to content

Commit

Permalink
Fix quitting during gameplay triggering neither saving nor alert
Browse files Browse the repository at this point in the history
Fixes #4409, reverts 443d517.
  • Loading branch information
J-rg committed Jan 8, 2021
1 parent 4cc6c0d commit a34e78d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion OpenEmu/OEGameDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ typedef NS_ENUM(NSUInteger, OEEmulationStatus)
OEEmulationStatusSetup,
/// The emulation has been requested to start
OEEmulationStatusStarting,
///
OEEmulationStatusPlaying,
///
OEEmulationStatusPaused,
/// After emulation stops, but before OEGameCoreManager is deallocated
OEEmulationStatusTerminating,
Expand All @@ -93,6 +95,8 @@ @interface OEGameDocument () <OEGameCoreOwner, OESystemBindingsObserver>
BOOL _pausedByGoingToBackground;
BOOL _isTerminatingEmulation;
BOOL _coreDidTerminateSuddenly;
/// Indicates whether the document is currently moving from the main window into a separate popout window.
BOOL _isUndocking;

// track if ROM was decompressed
NSString *_romPath;
Expand Down Expand Up @@ -519,6 +523,7 @@ - (void)OE_deviceDidDisconnectNotification:(NSNotification *)notification

- (void)showInSeparateWindowInFullScreen:(BOOL)fullScreen;
{
_isUndocking = YES;
NSWindow *window = [[NSWindow alloc]
initWithContentRect:NSZeroRect
styleMask:NSWindowStyleMaskTitled | NSWindowStyleMaskClosable |
Expand All @@ -532,6 +537,7 @@ - (void)showInSeparateWindowInFullScreen:(BOOL)fullScreen;
[self showWindows];

[self setEmulationPaused:NO];
_isUndocking = NO;
}

- (NSString *)displayName
Expand Down Expand Up @@ -1110,9 +1116,13 @@ + (BOOL)autosavesInPlace
return NO;
}

/// Returns YES if emulation is running or paused to prevent OpenEmu from quitting without warning/saving if the user attempts to quit the app during gameplay;
/// returns NO while undocking to prevent an ‘unsaved’ indicator from appearing inside the new popout window’s close button.
- (BOOL)isDocumentEdited
{
return NO;
if (_isUndocking)
return NO;
return _emulationStatus == OEEmulationStatusPlaying || _emulationStatus == OEEmulationStatusPaused;
}

- (void)canCloseDocumentWithDelegate:(id)delegate shouldCloseSelector:(SEL)shouldCloseSelector contextInfo:(void *)contextInfo
Expand Down

0 comments on commit a34e78d

Please sign in to comment.