From 0d1c954bc08207489e1e4c78e03717abe20d68d8 Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Fri, 26 Dec 2014 22:11:03 +0200 Subject: [PATCH] Fixed crash in game controller support code Joystick's startup and shutdown (of Native OS X backend) can be called more than once --- src/posix/cocoa/i_joystick.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/posix/cocoa/i_joystick.cpp b/src/posix/cocoa/i_joystick.cpp index a3bc1c0fa..29f98fcd1 100644 --- a/src/posix/cocoa/i_joystick.cpp +++ b/src/posix/cocoa/i_joystick.cpp @@ -739,6 +739,11 @@ IOKitJoystickManager* s_joystickManager; void I_StartupJoysticks() { + if (NULL != s_joystickManager) + { + return; + } + // HID Manager API is available on 10.5 (Darwin 9.x) or newer if (darwinVersion.major >= 9) @@ -750,6 +755,7 @@ void I_StartupJoysticks() void I_ShutdownJoysticks() { delete s_joystickManager; + s_joystickManager = NULL; } void I_GetJoysticks( TArray< IJoystickConfig* >& sticks )