]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix some crashes related to video subsystem not being reinitialized on vid_restart...
authoreihrul <eihrul@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 22 Jan 2011 21:38:07 +0000 (21:38 +0000)
committereihrul <eihrul@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 22 Jan 2011 21:38:07 +0000 (21:38 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@10718 d7cf8633-e32d-0410-b094-e92efae38249

vid_sdl.c

index 31e9cd926215099167be20d1ec07d16b105a8b4c..a9dd5c45db006ee9c36e75928aafa6a4c9d4fce5 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -700,7 +700,7 @@ void VID_Init (void)
 
        if (SDL_Init(SDL_INIT_VIDEO) < 0)
                Sys_Error ("Failed to init SDL video subsystem: %s", SDL_GetError());
-       vid_sdl_initjoysticksystem = SDL_Init(SDL_INIT_JOYSTICK) >= 0;
+       vid_sdl_initjoysticksystem = SDL_InitSubSystem(SDL_INIT_JOYSTICK) >= 0;
        if (vid_sdl_initjoysticksystem)
                Con_Printf("Failed to init SDL joystick subsystem: %s\n", SDL_GetError());
        vid_isfullscreen = false;
@@ -1260,6 +1260,8 @@ qboolean VID_InitModeSoft(viddef_mode_t *mode)
 
 qboolean VID_InitMode(viddef_mode_t *mode)
 {
+       if (!SDL_WasInit(SDL_INIT_VIDEO) && SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
+               Sys_Error ("Failed to init SDL video subsystem: %s", SDL_GetError());
        if (vid_soft.integer)
                return VID_InitModeSoft(mode);
        else
@@ -1271,6 +1273,12 @@ void VID_Shutdown (void)
        VID_SetMouse(false, false, false);
        VID_RestoreSystemGamma();
 
+#ifndef WIN32
+       if (icon)
+               SDL_FreeSurface(icon);
+       icon = NULL;
+#endif
+
        if (vid_softsurface)
                SDL_FreeSurface(vid_softsurface);
        vid_softsurface = NULL;