Fixed crash if no window has keyboard focus
authorSam Lantinga <slouken@libsdl.org>
Fri, 06 Dec 2013 16:12:18 -0800
changeset 8054 2a38ef3eeabb
parent 8053 495f4a047be1
child 8055 3e2f230a6d62
Fixed crash if no window has keyboard focus
src/video/cocoa/SDL_cocoamousetap.m
--- a/src/video/cocoa/SDL_cocoamousetap.m	Fri Dec 06 09:13:31 2013 -0800
+++ b/src/video/cocoa/SDL_cocoamousetap.m	Fri Dec 06 16:12:18 2013 -0800
@@ -63,7 +63,7 @@
     SDL_MouseEventTapData *tapdata = (SDL_MouseEventTapData*)refcon;
     SDL_Mouse *mouse = SDL_GetMouse();
     SDL_Window *window = SDL_GetKeyboardFocus();
-    NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
+    NSWindow *nswindow;
     NSRect windowRect;
     CGPoint eventLocation;
 
@@ -93,6 +93,7 @@
     }
 
     /* This is the same coordinate system as Cocoa uses. */
+    nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
     eventLocation = CGEventGetUnflippedLocation(event);
     windowRect = [nswindow contentRectForFrameRect:[nswindow frame]];