changeset 3897:37dab4a917c4 SDL-1.2

Check video driver mouse cursor pointers before using them
author Patrice Mandin <patmandin@gmail.com>
date Sun, 19 Nov 2006 14:07:32 +0000
parents 1a327643e741
children 899d07087694
files src/video/SDL_cursor.c
diffstat 1 files changed, 12 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/SDL_cursor.c	Mon Nov 13 03:58:22 2006 +0000
+++ b/src/video/SDL_cursor.c	Sun Nov 19 14:07:32 2006 +0000
@@ -188,7 +188,7 @@
 			   it needs to hide the old cursor before (possibly)
 			   showing the new one.  (But don't erase NULL cursor)
 			 */
-			if ( SDL_cursor ) {
+			if ( SDL_cursor && video->ShowWMCursor ) {
 				video->ShowWMCursor(this, NULL);
 			}
 		}
@@ -198,8 +198,11 @@
 	/* Draw the new mouse cursor */
 	if ( SDL_cursor && (SDL_cursorstate&CURSOR_VISIBLE) ) {
 		/* Use window manager cursor if possible */
-		if ( SDL_cursor->wm_cursor && 
-	             video->ShowWMCursor(this, SDL_cursor->wm_cursor) ) {
+		int show_wm_cursor = 0;
+		if ( SDL_cursor->wm_cursor && video->ShowWMCursor ) {
+			show_wm_cursor = video->ShowWMCursor(this, SDL_cursor->wm_cursor);
+		}
+		if ( show_wm_cursor ) {
 			SDL_cursorstate &= ~CURSOR_USINGSW;
 		} else {
 			SDL_cursorstate |= CURSOR_USINGSW;
@@ -219,7 +222,9 @@
 			SDL_EraseCursor(SDL_VideoSurface);
 		} else {
 			if ( video ) {
-				video->ShowWMCursor(this, NULL);
+				if ( video->ShowWMCursor ) {
+					video->ShowWMCursor(this, NULL);
+				}
 			}
 		}
 	}
@@ -248,7 +253,9 @@
 				SDL_free(cursor->save[0]);
 			}
 			if ( video && cursor->wm_cursor ) {
-				video->FreeWMCursor(this, cursor->wm_cursor);
+				if ( video->FreeWMCursor ) {
+					video->FreeWMCursor(this, cursor->wm_cursor);
+				}
 			}
 			SDL_free(cursor);
 		}