Fixed cursor leak when quitting the mouse subsystem
authorSam Lantinga <slouken@libsdl.org>
Sun, 21 Jul 2013 12:21:22 -0700
changeset 7493 7bfda8f0bfdf
parent 7492 98de3e4f1c36
child 7494 25575b2a188f
Fixed cursor leak when quitting the mouse subsystem
src/events/SDL_mouse.c
src/video/SDL_video.c
--- a/src/events/SDL_mouse.c	Sun Jul 21 11:52:16 2013 -0700
+++ b/src/events/SDL_mouse.c	Sun Jul 21 12:21:22 2013 -0700
@@ -361,6 +361,23 @@
 void
 SDL_MouseQuit(void)
 {
+    SDL_Cursor *cursor, *next;
+    SDL_Mouse *mouse = SDL_GetMouse();
+
+    SDL_ShowCursor(1);
+
+    cursor = mouse->cursors;
+    while (cursor) {
+        next = cursor->next;
+        SDL_FreeCursor(cursor);
+        cursor = next;
+    }
+
+    if (mouse->def_cursor && mouse->FreeCursor) {
+        mouse->FreeCursor(mouse->def_cursor);
+    }
+
+    SDL_zerop(mouse);
 }
 
 Uint32
--- a/src/video/SDL_video.c	Sun Jul 21 11:52:16 2013 -0700
+++ b/src/video/SDL_video.c	Sun Jul 21 12:21:22 2013 -0700
@@ -2247,8 +2247,6 @@
 
     SDL_EnableScreenSaver();
 
-    SDL_ShowCursor(1);
-
     /* Clean up the system video */
     while (_this->windows) {
         SDL_DestroyWindow(_this->windows);