From 8e1b1aa20150d4fb3340ceedc8bf9a615cef249d Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Mon, 2 Feb 2015 19:36:08 -0500 Subject: [PATCH] - Defer SDL subsystem initialization since it seems to cause conflicts with GUI toolkits on some systems. --- src/posix/sdl/hardware.cpp | 10 ++++++++++ src/posix/sdl/i_joystick.cpp | 11 ++++++++--- src/posix/sdl/i_main.cpp | 3 +-- src/posix/sdl/i_timer.cpp | 5 ++++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/posix/sdl/hardware.cpp b/src/posix/sdl/hardware.cpp index 25e19ff21a..75d6632664 100644 --- a/src/posix/sdl/hardware.cpp +++ b/src/posix/sdl/hardware.cpp @@ -66,10 +66,20 @@ void I_ShutdownGraphics () } if (Video) delete Video, Video = NULL; + + SDL_QuitSubSystem (SDL_INIT_VIDEO); } void I_InitGraphics () { + if (SDL_InitSubSystem (SDL_INIT_VIDEO) < 0) + { + I_FatalError ("Could not initialize SDL video:\n%s\n", SDL_GetError()); + return; + } + + Printf("Using video driver %s\n", SDL_GetCurrentVideoDriver()); + UCVarValue val; val.Bool = !!Args->CheckParm ("-devparm"); diff --git a/src/posix/sdl/i_joystick.cpp b/src/posix/sdl/i_joystick.cpp index 9b1d326aef..d99caeca9d 100644 --- a/src/posix/sdl/i_joystick.cpp +++ b/src/posix/sdl/i_joystick.cpp @@ -1,4 +1,4 @@ -#include +#include #include "doomdef.h" #include "templates.h" @@ -266,11 +266,16 @@ static SDLInputJoystickManager *JoystickManager; void I_StartupJoysticks() { - JoystickManager = new SDLInputJoystickManager(); + if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) >= 0) + JoystickManager = new SDLInputJoystickManager(); } void I_ShutdownJoysticks() { - delete JoystickManager; + if(JoystickManager) + { + delete JoystickManager; + SDL_QuitSubSystem(SDL_INIT_JOYSTICK); + } } void I_GetJoysticks(TArray &sticks) diff --git a/src/posix/sdl/i_main.cpp b/src/posix/sdl/i_main.cpp index ff700eff42..d60494d1a5 100644 --- a/src/posix/sdl/i_main.cpp +++ b/src/posix/sdl/i_main.cpp @@ -265,14 +265,13 @@ int main (int argc, char **argv) setlocale (LC_ALL, "C"); - if (SDL_Init (SDL_INIT_VIDEO|SDL_INIT_TIMER|SDL_INIT_NOPARACHUTE|SDL_INIT_JOYSTICK) == -1) + if (SDL_Init (0) < 0) { fprintf (stderr, "Could not initialize SDL:\n%s\n", SDL_GetError()); return -1; } atterm (SDL_Quit); - printf("Using video driver %s\n", SDL_GetCurrentVideoDriver()); printf("\n"); try diff --git a/src/posix/sdl/i_timer.cpp b/src/posix/sdl/i_timer.cpp index e3f9906b62..6255c8a96c 100644 --- a/src/posix/sdl/i_timer.cpp +++ b/src/posix/sdl/i_timer.cpp @@ -195,6 +195,9 @@ fixed_t I_GetTimeFrac (uint32 *ms) void I_InitTimer () { + if(SDL_InitSubSystem(SDL_INIT_TIMER) < 0) + I_FatalError("Could not initialize SDL timers:\n%s\n", SDL_GetError()); + I_GetTime = I_GetTimeSelect; I_WaitForTic = I_WaitForTicSelect; I_FreezeTime = I_FreezeTimeSelect; @@ -202,5 +205,5 @@ void I_InitTimer () void I_ShutdownTimer () { - + SDL_QuitSubSystem(SDL_INIT_TIMER); }