pcsx2: call XInitThreads at init

X11 isn't thread safe by default. It make sense in 1990 but it is ugly nowadays.

The trick is that is must called before any X11 function. So the only
safe place is at the start of the main.  Pcsx2App::OnInit() is the
sooner that I've found.
This commit is contained in:
Gregory Hainaut 2017-04-20 21:19:33 +02:00
parent 201c9cd2a4
commit 99180f5afb
2 changed files with 13 additions and 0 deletions

View File

@ -662,6 +662,7 @@ set(pcsx2FinalLibs
${ZLIB_LIBRARIES}
${AIO_LIBRARIES}
${GCOV_LIBRARIES}
${X11_LIBRARIES}
)
if(BUILTIN_GS)

View File

@ -424,8 +424,20 @@ protected:
}
};
#ifdef __unix__
#include <X11/Xlib.h>
#endif
bool Pcsx2App::OnInit()
{
#ifdef __unix__
// By default X11 isn't thread safe
// Typically it avoid a crash on Mesa when glthread is enabled on DRI2
//
// I guess it could be removed once we migrate to Wayland (post 2020)
XInitThreads();
#endif
EnableAllLogging();
Console.WriteLn("Interface is initializing. Entering Pcsx2App::OnInit!");