Sfoglia il codice sorgente

mouse: Ensure that the dummy default cursor is removed from the cursor list

In the case where a dummy cursor is created as the default cursor, make sure it is removed from the cursor list when freeing the default cursor.
Frank Praznik 1 anno fa
parent
commit
d60ebb06d1
1 ha cambiato i file con 14 aggiunte e 0 eliminazioni
  1. 14 0
      src/events/SDL_mouse.c

+ 14 - 0
src/events/SDL_mouse.c

@@ -233,12 +233,26 @@ void SDL_SetDefaultCursor(SDL_Cursor *cursor)
 
     if (mouse->def_cursor) {
         SDL_Cursor *default_cursor = mouse->def_cursor;
+        SDL_Cursor *prev, *curr;
 
         if (mouse->cur_cursor == mouse->def_cursor) {
             mouse->cur_cursor = NULL;
         }
         mouse->def_cursor = NULL;
 
+        for (prev = NULL, curr = mouse->cursors; curr;
+             prev = curr, curr = curr->next) {
+            if (curr == default_cursor) {
+                if (prev) {
+                    prev->next = curr->next;
+                } else {
+                    mouse->cursors = curr->next;
+                }
+
+                break;
+            }
+        }
+
         if (mouse->FreeCursor && default_cursor->driverdata) {
             mouse->FreeCursor(default_cursor);
         } else {