Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Handle assertion failures when SDL_Init() isn't called.

  • Loading branch information
icculus committed Jan 13, 2010
1 parent ce632ae commit 4b65e24da80c8740853c1081c629b643952abbe3

File 1 of 1 in 4b65e24

@@ -351,8 +351,19 @@ SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file,
int line)
{
static int assertion_running = 0;
static SDL_SpinLock spinlock = 0;
SDL_assert_state state = SDL_ASSERTION_IGNORE;

SDL_AtomicLock(&spinlock);
if (assertion_mutex == NULL) { /* never called SDL_Init()? */
assertion_mutex = SDL_CreateMutex();
if (assertion_mutex == NULL) {
SDL_AtomicUnlock(&spinlock);
return SDL_ASSERTION_IGNORE; /* oh well, I guess. */
}
}
SDL_AtomicUnlock(&spinlock);

if (SDL_LockMutex(assertion_mutex) < 0) {
return SDL_ASSERTION_IGNORE; /* oh well, I guess. */
}

0 comments on commit 4b65e24

Please sign in to comment.