From 1ff94c5f2d5d027f6e6186234f22efd4ed5b6034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Mon, 25 Jul 2016 07:54:17 +0200 Subject: [PATCH] DolphinWX: Prevent crash with Wiimote connected on start wxWidgets causes a segfault if Host_ConnectWiimote is called and we try to create an event from the Wiimote scanner thread while the GUI is still initialising. --- Source/Core/DolphinWX/Main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Core/DolphinWX/Main.cpp b/Source/Core/DolphinWX/Main.cpp index 305cae3b7d..9eef4b3d0c 100644 --- a/Source/Core/DolphinWX/Main.cpp +++ b/Source/Core/DolphinWX/Main.cpp @@ -82,6 +82,8 @@ std::string wxStringTranslator(const char*); CFrame* main_frame = nullptr; +static std::mutex s_init_mutex; + bool DolphinApp::Initialize(int& c, wxChar** v) { #if defined HAVE_X11 && HAVE_X11 @@ -94,6 +96,7 @@ bool DolphinApp::Initialize(int& c, wxChar** v) bool DolphinApp::OnInit() { + std::lock_guard lk(s_init_mutex); if (!wxApp::OnInit()) return false; @@ -548,6 +551,7 @@ bool Host_RendererIsFullscreen() void Host_ConnectWiimote(int wm_idx, bool connect) { + std::lock_guard lk(s_init_mutex); if (connect) { wxCommandEvent event(wxEVT_HOST_COMMAND, IDM_FORCE_CONNECT_WIIMOTE1 + wm_idx);