From b808c61113c50f1395270600bfb1d55935c1a252 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Thu, 13 Sep 2018 22:02:02 -0700 Subject: [PATCH] Try and make alcDestroyContext more resilient --- project/src/media/openal/OpenALBindings.cpp | 28 +++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/project/src/media/openal/OpenALBindings.cpp b/project/src/media/openal/OpenALBindings.cpp index 870c9a18e..67862cb1f 100644 --- a/project/src/media/openal/OpenALBindings.cpp +++ b/project/src/media/openal/OpenALBindings.cpp @@ -3186,7 +3186,19 @@ namespace lime { al_gc_mutex.Lock (); ALCcontext* alcContext = (ALCcontext*)val_data (context); - alcObjects.erase (alcContext); + + if (alcObjects.find (alcContext) != alcObjects.end ()) { + + alcObjects.erase (alcContext); + + } + + if (alcContext == alcGetCurrentContext ()) { + + alcMakeContextCurrent (0); + + } + alcDestroyContext (alcContext); al_gc_mutex.Unlock (); @@ -3197,7 +3209,19 @@ namespace lime { al_gc_mutex.Lock (); ALCcontext* alcContext = (ALCcontext*)context->ptr; - alcObjects.erase (alcContext); + + if (alcObjects.find (alcContext) != alcObjects.end ()) { + + alcObjects.erase (alcContext); + + } + + if (alcContext == alcGetCurrentContext ()) { + + alcMakeContextCurrent (0); + + } + alcDestroyContext (alcContext); al_gc_mutex.Unlock ();