Skip to content
Snippets Groups Projects
Commit 205d9fc2 authored by Rye Mutt's avatar Rye Mutt :bread:
Browse files

Fix crash deep in gtk due to weird init order requirements for SDL/GTK mixture...

parent 634ae1ab
No related branches found
No related tags found
No related merge requests found
...@@ -197,14 +197,12 @@ LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks, ...@@ -197,14 +197,12 @@ LLWindowSDL::LLWindowSDL(LLWindowCallbacks* callbacks,
{ {
SDL_SetMainReady(); SDL_SetMainReady();
if (SDL_Init(0) != 0) if (SDL_InitSubSystem(SDL_INIT_EVENTS|SDL_INIT_VIDEO|SDL_INIT_GAMECONTROLLER|SDL_INIT_JOYSTICK) != 0)
{ {
LL_WARNS() << "Failed to initialize SDL due to error: " << SDL_GetError() << LL_ENDL; LL_WARNS() << "Failed to initialize SDL due to error: " << SDL_GetError() << LL_ENDL;
return; return;
} }
SDL_InitSubSystem(SDL_INIT_EVENTS);
// Initialize the keyboard // Initialize the keyboard
gKeyboard = new LLKeyboardSDL(); gKeyboard = new LLKeyboardSDL();
gKeyboard->setCallbacks(callbacks); gKeyboard->setCallbacks(callbacks);
...@@ -418,13 +416,6 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B ...@@ -418,13 +416,6 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
mGrabbyKeyFlags = 0; mGrabbyKeyFlags = 0;
mReallyCapturedCount = 0; mReallyCapturedCount = 0;
if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
{
LL_INFOS() << "sdl_init() failed! " << SDL_GetError() << LL_ENDL;
setupFailure("sdl_init() failure, window creation error", "error", OSMB_OK);
return false;
}
SDL_version c_sdl_version; SDL_version c_sdl_version;
SDL_VERSION(&c_sdl_version); SDL_VERSION(&c_sdl_version);
LL_INFOS() << "Compiled against SDL " LL_INFOS() << "Compiled against SDL "
...@@ -678,8 +669,6 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B ...@@ -678,8 +669,6 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
LL_WARNS() << "OpenGL context creation failure. SDL: " << SDL_GetError() << LL_ENDL; LL_WARNS() << "OpenGL context creation failure. SDL: " << SDL_GetError() << LL_ENDL;
setupFailure("Context creation error", "Error", OSMB_OK); setupFailure("Context creation error", "Error", OSMB_OK);
SDL_DestroyWindow(mWindow); SDL_DestroyWindow(mWindow);
mWindow = nullptr;
SDL_QuitSubSystem(SDL_INIT_VIDEO);
return FALSE; return FALSE;
} }
if (SDL_GL_MakeCurrent(mWindow, mGLContext) != 0) if (SDL_GL_MakeCurrent(mWindow, mGLContext) != 0)
...@@ -690,7 +679,6 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B ...@@ -690,7 +679,6 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
mGLContext = nullptr; mGLContext = nullptr;
SDL_DestroyWindow(mWindow); SDL_DestroyWindow(mWindow);
mWindow = nullptr; mWindow = nullptr;
SDL_QuitSubSystem(SDL_INIT_VIDEO);
return FALSE; return FALSE;
} }
...@@ -764,7 +752,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B ...@@ -764,7 +752,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
/* Grab the window manager specific information */ /* Grab the window manager specific information */
SDL_SysWMinfo info; SDL_SysWMinfo info;
SDL_VERSION(&info.version); SDL_VERSION(&info.version);
if ( SDL_GetWindowWMInfo(mWindow, &info) ) if ( SDL_GetWindowWMInfo(mWindow, &info) == SDL_TRUE)
{ {
/* Save the information for later use */ /* Save the information for later use */
if ( info.subsystem == SDL_SYSWM_X11 ) if ( info.subsystem == SDL_SYSWM_X11 )
...@@ -780,7 +768,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B ...@@ -780,7 +768,7 @@ BOOL LLWindowSDL::createContext(int x, int y, int width, int height, int bits, B
} }
else else
{ {
LL_WARNS() << "We're not running under any known WM. Wild." LL_WARNS() << "We're not running under any known WM. SDL Err: " << SDL_GetError()
<< LL_ENDL; << LL_ENDL;
} }
#endif // LL_X11 #endif // LL_X11
...@@ -856,8 +844,6 @@ void LLWindowSDL::destroyContext() ...@@ -856,8 +844,6 @@ void LLWindowSDL::destroyContext()
// Clean up remaining GL state before blowing away window // Clean up remaining GL state before blowing away window
LL_INFOS() << "shutdownGL begins" << LL_ENDL; LL_INFOS() << "shutdownGL begins" << LL_ENDL;
gGLManager.shutdownGL(); gGLManager.shutdownGL();
LL_INFOS() << "SDL_QuitSS/VID begins" << LL_ENDL;
SDL_QuitSubSystem(SDL_INIT_VIDEO); // *FIX: this might be risky...
mWindow = NULL; mWindow = NULL;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment