From 99180f5afbe012d87ef2cd68c3250e3dde90f396 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Thu, 20 Apr 2017 21:19:33 +0200 Subject: [PATCH] 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. --- pcsx2/CMakeLists.txt | 1 + pcsx2/gui/AppInit.cpp | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index dc3efb50bc..280e17dea7 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -662,6 +662,7 @@ set(pcsx2FinalLibs ${ZLIB_LIBRARIES} ${AIO_LIBRARIES} ${GCOV_LIBRARIES} + ${X11_LIBRARIES} ) if(BUILTIN_GS) diff --git a/pcsx2/gui/AppInit.cpp b/pcsx2/gui/AppInit.cpp index 20683f14fc..27ad012b26 100644 --- a/pcsx2/gui/AppInit.cpp +++ b/pcsx2/gui/AppInit.cpp @@ -424,8 +424,20 @@ protected: } }; +#ifdef __unix__ +#include +#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!");