Skip to content

Commit

Permalink
Fixed assertion when quickly toggling from fullscreen back to fullscr…
Browse files Browse the repository at this point in the history
…een:

"Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'backgroundWindows not nil in enterFullScreenTransitionWithOptions:animated:activatingIt:'"

To reproduce this, run testsprite2, press Alt-Enter once, again while it's animating to fullscreen, and then again while it's animating out of fullscreen.
  • Loading branch information
slouken committed Nov 12, 2013
1 parent 8f8070d commit cb190b8
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -184,10 +184,6 @@ -(void) resumeVisibleObservation
}
}

-(BOOL) canSetFullscreenState:(BOOL) state;
{
}

-(BOOL) setFullscreenState:(BOOL) state;
{
SDL_Window *window = _data->window;
Expand Down Expand Up @@ -228,7 +224,7 @@ -(BOOL) setFullscreenState:(BOOL) state;
return YES;
}

[nswindow performSelector: @selector(toggleFullScreen:) withObject:nswindow];
[nswindow performSelectorOnMainThread: @selector(toggleFullScreen:) withObject:nswindow waitUntilDone:NO];
return YES;
}

Expand Down Expand Up @@ -433,19 +429,27 @@ - (void)windowWillEnterFullScreen:(NSNotification *)aNotification
[nswindow setStyleMask:NSBorderlessWindowMask];
}
}

isFullscreen = YES;
inFullscreenTransition = YES;
}

- (void)windowDidEnterFullScreen:(NSNotification *)aNotification
{
SDL_Window *window = _data->window;

inFullscreenTransition = NO;

if (pendingWindowOperation == PENDING_OPERATION_LEAVE_FULLSCREEN) {
pendingWindowOperation = PENDING_OPERATION_NONE;
[self setFullscreenState:NO];
} else {
pendingWindowOperation = PENDING_OPERATION_NONE;
/* Force the size change event in case it was delivered earlier
while the window was still animating into place.
*/
window->w = 0;
window->h = 0;
[self windowDidResize:aNotification];
}
}
Expand All @@ -465,6 +469,7 @@ - (void)windowWillExitFullScreen:(NSNotification *)aNotification

- (void)windowDidExitFullScreen:(NSNotification *)aNotification
{
SDL_Window *window = _data->window;
NSWindow *nswindow = _data->nswindow;

inFullscreenTransition = NO;
Expand All @@ -477,6 +482,11 @@ - (void)windowDidExitFullScreen:(NSNotification *)aNotification
[nswindow miniaturize:nil];
} else {
pendingWindowOperation = PENDING_OPERATION_NONE;
/* Force the size change event in case it was delivered earlier
while the window was still animating into place.
*/
window->w = 0;
window->h = 0;
[self windowDidResize:aNotification];
}
}
Expand Down

0 comments on commit cb190b8

Please sign in to comment.