From 39bad809c3940acf3baa31bef5449d7bf467e9d2 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 15 Jun 2014 11:59:16 -0400 Subject: [PATCH] Mac: Fixed crash when returning from a fullscreen Space on shutdown. --- src/video/cocoa/SDL_cocoakeyboard.m | 4 ++++ src/video/cocoa/SDL_cocoamouse.m | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/video/cocoa/SDL_cocoakeyboard.m b/src/video/cocoa/SDL_cocoakeyboard.m index 85bf9a067..c68ee8b8a 100644 --- a/src/video/cocoa/SDL_cocoakeyboard.m +++ b/src/video/cocoa/SDL_cocoakeyboard.m @@ -565,6 +565,10 @@ void 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 diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index a78fb2589..d231684a2 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -349,8 +349,11 @@ Cocoa_HandleMouseEvent(_THIS, NSEvent *event) } SDL_Mouse *mouse = SDL_GetMouse(); - SDL_MouseData *driverdata = (SDL_MouseData*)mouse->driverdata; + if (!driverdata) { + return; /* can happen when returning from fullscreen Space on shutdown */ + } + const SDL_bool seenWarp = driverdata->seenWarp; driverdata->seenWarp = NO;