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

Commit

Permalink
Handle assertion failures when SDL_Init() isn't called.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jan 13, 2010
1 parent ce632ae commit 4b65e24
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/SDL_assert.c
Expand Up @@ -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. */
}
Expand Down

0 comments on commit 4b65e24

Please sign in to comment.