diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 54611bf36d..170e4335b3 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -1168,6 +1168,12 @@ void SDL_QuitMouse(void) } SDL_free(SDL_mice); SDL_mice = NULL; + + if (mouse->internal) { + SDL_free(mouse->internal); + mouse->internal = NULL; + } + SDL_zerop(mouse); } bool SDL_SetRelativeMouseTransform(SDL_MouseMotionTransformCallback transform, void *userdata) diff --git a/src/video/cocoa/SDL_cocoamouse.m b/src/video/cocoa/SDL_cocoamouse.m index f8f582972f..cbd935335e 100644 --- a/src/video/cocoa/SDL_cocoamouse.m +++ b/src/video/cocoa/SDL_cocoamouse.m @@ -373,12 +373,12 @@ bool Cocoa_InitMouse(SDL_VideoDevice *_this) { NSPoint location; SDL_Mouse *mouse = SDL_GetMouse(); - SDL_MouseData *internal = (SDL_MouseData *)SDL_calloc(1, sizeof(SDL_MouseData)); - if (internal == NULL) { + SDL_MouseData *data = (SDL_MouseData *)SDL_calloc(1, sizeof(SDL_MouseData)); + if (data == NULL) { return false; } - mouse->internal = internal; + mouse->internal = data; mouse->CreateCursor = Cocoa_CreateCursor; mouse->CreateSystemCursor = Cocoa_CreateSystemCursor; mouse->ShowCursor = Cocoa_ShowCursor; @@ -585,13 +585,6 @@ void Cocoa_HandleMouseWarp(CGFloat x, CGFloat y) void Cocoa_QuitMouse(SDL_VideoDevice *_this) { - SDL_Mouse *mouse = SDL_GetMouse(); - if (mouse) { - if (mouse->internal) { - SDL_free(mouse->internal); - mouse->internal = NULL; - } - } } #endif // SDL_VIDEO_DRIVER_COCOA