mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-06 03:18:13 +00:00
Fixed crash if mouse functions are used after video quit
This commit is contained in:
@@ -1168,6 +1168,12 @@ void SDL_QuitMouse(void)
|
|||||||
}
|
}
|
||||||
SDL_free(SDL_mice);
|
SDL_free(SDL_mice);
|
||||||
SDL_mice = NULL;
|
SDL_mice = NULL;
|
||||||
|
|
||||||
|
if (mouse->internal) {
|
||||||
|
SDL_free(mouse->internal);
|
||||||
|
mouse->internal = NULL;
|
||||||
|
}
|
||||||
|
SDL_zerop(mouse);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SDL_SetRelativeMouseTransform(SDL_MouseMotionTransformCallback transform, void *userdata)
|
bool SDL_SetRelativeMouseTransform(SDL_MouseMotionTransformCallback transform, void *userdata)
|
||||||
|
@@ -373,12 +373,12 @@ bool Cocoa_InitMouse(SDL_VideoDevice *_this)
|
|||||||
{
|
{
|
||||||
NSPoint location;
|
NSPoint location;
|
||||||
SDL_Mouse *mouse = SDL_GetMouse();
|
SDL_Mouse *mouse = SDL_GetMouse();
|
||||||
SDL_MouseData *internal = (SDL_MouseData *)SDL_calloc(1, sizeof(SDL_MouseData));
|
SDL_MouseData *data = (SDL_MouseData *)SDL_calloc(1, sizeof(SDL_MouseData));
|
||||||
if (internal == NULL) {
|
if (data == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mouse->internal = internal;
|
mouse->internal = data;
|
||||||
mouse->CreateCursor = Cocoa_CreateCursor;
|
mouse->CreateCursor = Cocoa_CreateCursor;
|
||||||
mouse->CreateSystemCursor = Cocoa_CreateSystemCursor;
|
mouse->CreateSystemCursor = Cocoa_CreateSystemCursor;
|
||||||
mouse->ShowCursor = Cocoa_ShowCursor;
|
mouse->ShowCursor = Cocoa_ShowCursor;
|
||||||
@@ -585,13 +585,6 @@ void Cocoa_HandleMouseWarp(CGFloat x, CGFloat y)
|
|||||||
|
|
||||||
void Cocoa_QuitMouse(SDL_VideoDevice *_this)
|
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
|
#endif // SDL_VIDEO_DRIVER_COCOA
|
||||||
|
Reference in New Issue
Block a user