Mac: Fixed crash when returning from a fullscreen Space on shutdown.
authorRyan C. Gordon <icculus@icculus.org>
Sun, 15 Jun 2014 11:59:16 -0400
changeset 8862 523abf9a4fb4
parent 8861 dfc5e5220e54
child 8863 557cd26c10b6
Mac: Fixed crash when returning from a fullscreen Space on shutdown.
src/video/cocoa/SDL_cocoakeyboard.m
src/video/cocoa/SDL_cocoamouse.m
--- a/src/video/cocoa/SDL_cocoakeyboard.m	Sun Jun 15 01:19:01 2014 -0400
+++ b/src/video/cocoa/SDL_cocoakeyboard.m	Sun Jun 15 11:59:16 2014 -0400
@@ -565,6 +565,10 @@
 Cocoa_HandleKeyEvent(_THIS, NSEvent *event)
 {
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
+    if (!data) {
+        return;  /* can happen when returning from fullscreen Space on shutdown */
+    }
+
     unsigned short scancode = [event keyCode];
     SDL_Scancode code;
 #if 0
--- a/src/video/cocoa/SDL_cocoamouse.m	Sun Jun 15 01:19:01 2014 -0400
+++ b/src/video/cocoa/SDL_cocoamouse.m	Sun Jun 15 11:59:16 2014 -0400
@@ -349,8 +349,11 @@
     }
 
     SDL_Mouse *mouse = SDL_GetMouse();
+    SDL_MouseData *driverdata = (SDL_MouseData*)mouse->driverdata;
+    if (!driverdata) {
+        return;  /* can happen when returning from fullscreen Space on shutdown */
+    }
 
-    SDL_MouseData *driverdata = (SDL_MouseData*)mouse->driverdata;
     const SDL_bool seenWarp = driverdata->seenWarp;
     driverdata->seenWarp = NO;