From d2910912a4b11c1bddd296de6ec7eb318a74ddf9 Mon Sep 17 00:00:00 2001 From: Soren Jorvang Date: Sat, 19 Feb 2011 21:53:53 +0000 Subject: [PATCH] XInitThreads() must be the very first Xlib function called or else some X state will have initialized mutexes and some won't, leading to unpredictable results depending on the feature set compiled into wxWidgets and so on. wxGTK starts by calling Xlib functions indirectly through gdk very early on, so we must hook into wxApp::Initialize(). I believe this should properly fix issue 1540. In case of problems, please reopen that issue. If you see XLockMutex in a backtrace, that's a pretty good indication. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@7205 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/DolphinWX/Src/Main.cpp | 12 ++++++++---- Source/Core/DolphinWX/Src/Main.h | 1 + Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index d05840d941..357050675c 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -89,6 +89,14 @@ LONG WINAPI MyUnhandledExceptionFilter(LPEXCEPTION_POINTERS e) { } #endif +bool DolphinApp::Initialize(int& c, wxChar **v) +{ +#if defined HAVE_X11 && HAVE_X11 + XInitThreads(); +#endif + return wxApp::Initialize(c, v); +} + // The `main program' equivalent that creates the main window and return the main frame bool DolphinApp::OnInit() @@ -328,10 +336,6 @@ bool DolphinApp::OnInit() SetTopWindow(main_frame); main_frame->SetMinSize(wxSize(400, 300)); -#if defined HAVE_X11 && HAVE_X11 - XInitThreads(); -#endif - // Postpone final actions until event handler is running. // Updating the game list makes use of wxProgressDialog which may // only be run after OnInit() when the event handler is running. diff --git a/Source/Core/DolphinWX/Src/Main.h b/Source/Core/DolphinWX/Src/Main.h index 0bcfa4a325..0fb99fcfd4 100644 --- a/Source/Core/DolphinWX/Src/Main.h +++ b/Source/Core/DolphinWX/Src/Main.h @@ -31,6 +31,7 @@ private: bool OnInit(); int OnExit(); void OnFatalException(); + bool Initialize(int& c, wxChar **v); void InitLanguageSupport(); void MacOpenFile(const wxString &fileName); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp index 10a3c20382..cd0ea26872 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp @@ -489,7 +489,7 @@ bool OpenGL_Create(int _iwidth, int _iheight) if (GLWin.vi == NULL) { ERROR_LOG(VIDEO, "Could not choose visual (glXChooseVisual)"); - exit(0); + return false; } } } @@ -501,7 +501,7 @@ bool OpenGL_Create(int _iwidth, int _iheight) if (!GLWin.ctx) { PanicAlert("Couldn't Create GLX context.Quit"); - exit(0); // TODO: Don't bring down entire Emu + return false; } GLWin.x = _tx;