From 8c2c744ad59bc4c138d9a9ed85db22a5ad525e10 Mon Sep 17 00:00:00 2001 From: Alfred Reynolds Date: Fri, 13 Jun 2014 10:50:24 -0700 Subject: [PATCH] - fixed crash if you removed a device twice, the deviceRef is invalid if removed from the removed device callback (added in http://hg.libsdl.org/SDL/rev/d4e4d0fcda03 ). --- src/joystick/darwin/SDL_sysjoystick.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/joystick/darwin/SDL_sysjoystick.c b/src/joystick/darwin/SDL_sysjoystick.c index 757cf59305252..9ad8c44b82283 100644 --- a/src/joystick/darwin/SDL_sysjoystick.c +++ b/src/joystick/darwin/SDL_sysjoystick.c @@ -139,6 +139,7 @@ JoystickDeviceWasRemovedCallback(void *ctx, IOReturn result, void *sender) { recDevice *device = (recDevice *) ctx; device->removed = 1; + device->deviceRef = NULL; // deviceRef was invalidated due to the remove #if SDL_HAPTIC_IOKIT MacHaptic_MaybeRemoveDevice(device->ffservice); #endif @@ -603,6 +604,7 @@ SDL_SYS_JoystickDetect() SDL_bool SDL_SYS_JoystickNeedsPolling() { + // BUGBUG - only works if someone else is pumping the CFRunLoop... return s_bDeviceAdded || s_bDeviceRemoved; }