Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Make assert dialog work on Cocoa target even if we haven't initialize…
Browse files Browse the repository at this point in the history
…d video.
  • Loading branch information
icculus committed Apr 20, 2011
1 parent 576e21d commit 19396a8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/video/cocoa/SDL_cocoavideo.m
Expand Up @@ -20,6 +20,7 @@
*/
#include "SDL_config.h"

#include "SDL.h"
#include "SDL_endian.h"
#include "SDL_cocoavideo.h"
#include "SDL_cocoashape.h"
Expand Down Expand Up @@ -217,6 +218,14 @@
SDL_assert_state
SDL_PromptAssertion_cocoa(const SDL_assert_data *data)
{
const int initialized = (SDL_WasInit(SDL_INIT_VIDEO) != 0);
if (!initialized) {
if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1) {
fprintf(stderr, "Assertion failed AND couldn't init video mode!\n");
return SDL_ASSERTION_BREAK; /* oh well, crash hard. */
}
}

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

NSString *msg = [NSString stringWithFormat:
Expand All @@ -242,6 +251,11 @@
[alert addButtonWithTitle:@"Always Ignore"];
const NSInteger clicked = [alert runModal];
[pool release];

if (!initialized) {
SDL_QuitSubSystem(SDL_INIT_VIDEO);
}

return (SDL_assert_state) (clicked - NSAlertFirstButtonReturn);
}

Expand Down

0 comments on commit 19396a8

Please sign in to comment.