From 031a8f51f856c8ca83710c371cecaacc7fa61a53 Mon Sep 17 00:00:00 2001 From: Aaron Culliney Date: Sun, 21 Dec 2014 13:51:45 -0800 Subject: [PATCH] Prevent some segfaults when shutting down on Linux --- src/audio/soundcore-openal.c | 4 ++++ src/interface.c | 4 +++- src/video/glvideo.c | 6 +++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/audio/soundcore-openal.c b/src/audio/soundcore-openal.c index 90e51af9..1883465e 100644 --- a/src/audio/soundcore-openal.c +++ b/src/audio/soundcore-openal.c @@ -748,6 +748,10 @@ static long OpenALCreateSoundBuffer(ALBufferParamsStruct *params, ALSoundBufferS static long OpenALDestroySoundBuffer(ALSoundBufferStruct **soundbuf_struct) { + if (!*soundbuf_struct) { + // already dealloced + return 0; + } LOG("OpenALDestroySoundBuffer ..."); ALVoice *voice = (*soundbuf_struct)->_this; ALint source = voice->source; diff --git a/src/interface.c b/src/interface.c index 5a046664..8a170991 100644 --- a/src/interface.c +++ b/src/interface.c @@ -1275,8 +1275,10 @@ void c_interface_parameters() #ifdef __linux__ LOG("Back to Linux, w00t!\n"); #endif + SpkrDestroy(); + MB_Destroy(); + video_shutdown(); - //audio_shutdown(); TODO : fixme ... exit( 0 ); } } diff --git a/src/video/glvideo.c b/src/video/glvideo.c index f8ff35a3..a0b3e183 100644 --- a/src/video/glvideo.c +++ b/src/video/glvideo.c @@ -685,13 +685,14 @@ static void gldriver_reshape(int w, int h) { } #if USE_GLUT +static int glutWindow = -1; static void gldriver_init_glut(GLuint fbo) { glutInit(&argc, argv); glutInitDisplayMode(/*GLUT_DOUBLE|*/GLUT_RGBA|GLUT_DEPTH); glutInitWindowSize(windowWidth, windowHeight); //glutInitContextVersion(4, 0); -- Is this needed? glutInitContextProfile(GLUT_CORE_PROFILE); - glutCreateWindow(PACKAGE_NAME); + glutWindow = glutCreateWindow(PACKAGE_NAME); GL_ERRQUIT("GLUT initialization"); if (glewInit()) { @@ -748,6 +749,9 @@ void video_driver_reshape(int w, int h) { } void video_driver_shutdown(void) { +#if USE_GLUT + glutDestroyWindow(glutWindow); +#endif gldriver_shutdown(); }