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.
main
Frank Praznik 2023-08-16 13:46:14 -04:00
parent e58c2731fe
commit d60ebb06d1
1 changed files with 14 additions and 0 deletions

View File

@ -233,12 +233,26 @@ void SDL_SetDefaultCursor(SDL_Cursor *cursor)
if (mouse->def_cursor) { if (mouse->def_cursor) {
SDL_Cursor *default_cursor = mouse->def_cursor; SDL_Cursor *default_cursor = mouse->def_cursor;
SDL_Cursor *prev, *curr;
if (mouse->cur_cursor == mouse->def_cursor) { if (mouse->cur_cursor == mouse->def_cursor) {
mouse->cur_cursor = NULL; mouse->cur_cursor = NULL;
} }
mouse->def_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) { if (mouse->FreeCursor && default_cursor->driverdata) {
mouse->FreeCursor(default_cursor); mouse->FreeCursor(default_cursor);
} else { } else {