From 58e3dc3d52204d71d0e0402b9308fd675064d87e Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Tue, 24 Apr 2012 21:41:01 -0700 Subject: [PATCH] Add a SIGTRAP for when alGetError is called without a context --- OpenAL32/alError.c | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/OpenAL32/alError.c b/OpenAL32/alError.c index 56f4248e..d18c1867 100644 --- a/OpenAL32/alError.c +++ b/OpenAL32/alError.c @@ -28,21 +28,6 @@ ALboolean TrapALError = AL_FALSE; -AL_API ALenum AL_APIENTRY alGetError(void) -{ - ALCcontext *Context; - ALenum errorCode; - - Context = GetContextRef(); - if(!Context) return AL_INVALID_OPERATION; - - errorCode = ExchangeInt(&Context->LastError, AL_NO_ERROR); - - ALCcontext_DecRef(Context); - - return errorCode; -} - ALvoid alSetError(ALCcontext *Context, ALenum errorCode) { if(TrapALError) @@ -57,3 +42,30 @@ ALvoid alSetError(ALCcontext *Context, ALenum errorCode) } CompExchangeInt(&Context->LastError, AL_NO_ERROR, errorCode); } + +AL_API ALenum AL_APIENTRY alGetError(void) +{ + ALCcontext *Context; + ALenum errorCode; + + Context = GetContextRef(); + if(!Context) + { + if(TrapALError) + { +#ifdef _WIN32 + if(IsDebuggerPresent()) + DebugBreak(); +#elif defined(SIGTRAP) + raise(SIGTRAP); +#endif + } + return AL_INVALID_OPERATION; + } + + errorCode = ExchangeInt(&Context->LastError, AL_NO_ERROR); + + ALCcontext_DecRef(Context); + + return errorCode; +}