Prevent some segfaults when shutting down on Linux

This commit is contained in:
Aaron Culliney 2014-12-21 13:51:45 -08:00
parent 5f03582351
commit 031a8f51f8
3 changed files with 12 additions and 2 deletions

View File

@ -748,6 +748,10 @@ static long OpenALCreateSoundBuffer(ALBufferParamsStruct *params, ALSoundBufferS
static long OpenALDestroySoundBuffer(ALSoundBufferStruct **soundbuf_struct) static long OpenALDestroySoundBuffer(ALSoundBufferStruct **soundbuf_struct)
{ {
if (!*soundbuf_struct) {
// already dealloced
return 0;
}
LOG("OpenALDestroySoundBuffer ..."); LOG("OpenALDestroySoundBuffer ...");
ALVoice *voice = (*soundbuf_struct)->_this; ALVoice *voice = (*soundbuf_struct)->_this;
ALint source = voice->source; ALint source = voice->source;

View File

@ -1275,8 +1275,10 @@ void c_interface_parameters()
#ifdef __linux__ #ifdef __linux__
LOG("Back to Linux, w00t!\n"); LOG("Back to Linux, w00t!\n");
#endif #endif
SpkrDestroy();
MB_Destroy();
video_shutdown(); video_shutdown();
//audio_shutdown(); TODO : fixme ...
exit( 0 ); exit( 0 );
} }
} }

View File

@ -685,13 +685,14 @@ static void gldriver_reshape(int w, int h) {
} }
#if USE_GLUT #if USE_GLUT
static int glutWindow = -1;
static void gldriver_init_glut(GLuint fbo) { static void gldriver_init_glut(GLuint fbo) {
glutInit(&argc, argv); glutInit(&argc, argv);
glutInitDisplayMode(/*GLUT_DOUBLE|*/GLUT_RGBA|GLUT_DEPTH); glutInitDisplayMode(/*GLUT_DOUBLE|*/GLUT_RGBA|GLUT_DEPTH);
glutInitWindowSize(windowWidth, windowHeight); glutInitWindowSize(windowWidth, windowHeight);
//glutInitContextVersion(4, 0); -- Is this needed? //glutInitContextVersion(4, 0); -- Is this needed?
glutInitContextProfile(GLUT_CORE_PROFILE); glutInitContextProfile(GLUT_CORE_PROFILE);
glutCreateWindow(PACKAGE_NAME); glutWindow = glutCreateWindow(PACKAGE_NAME);
GL_ERRQUIT("GLUT initialization"); GL_ERRQUIT("GLUT initialization");
if (glewInit()) { if (glewInit()) {
@ -748,6 +749,9 @@ void video_driver_reshape(int w, int h) {
} }
void video_driver_shutdown(void) { void video_driver_shutdown(void) {
#if USE_GLUT
glutDestroyWindow(glutWindow);
#endif
gldriver_shutdown(); gldriver_shutdown();
} }