Fixes #2611 #2610, Touch events cause crash on Android, thanks Alvin & Sylvain
authorGabriel Jacobo <gabomdq@gmail.com>
Sat, 28 Jun 2014 12:36:44 -0300
changeset 8963 f94215b55583
parent 8962 c593cbef6d7d
child 8964 d9ac759bb62a
Fixes #2611 #2610, Touch events cause crash on Android, thanks Alvin & Sylvain This bug was introduced on this rev: https://hg.libsdl.org/SDL/rev/dc80dc0bd22e
src/events/SDL_mouse.c
src/video/android/SDL_androidtouch.c
--- a/src/events/SDL_mouse.c	Sat Jun 28 12:17:29 2014 -0300
+++ b/src/events/SDL_mouse.c	Sat Jun 28 12:36:44 2014 -0300
@@ -142,7 +142,7 @@
     SDL_Mouse *mouse = SDL_GetMouse();
     SDL_bool inWindow = SDL_TRUE;
 
-    if ((window->flags & SDL_WINDOW_MOUSE_CAPTURE) == 0) {
+    if (window != NULL && ((window->flags & SDL_WINDOW_MOUSE_CAPTURE) == 0)) {
         int w, h;
         SDL_GetWindowSize(window, &w, &h);
         if (x < 0 || y < 0 || x >= w || y >= h) {
--- a/src/video/android/SDL_androidtouch.c	Sat Jun 28 12:17:29 2014 -0300
+++ b/src/video/android/SDL_androidtouch.c	Sat Jun 28 12:36:44 2014 -0300
@@ -86,9 +86,9 @@
             /* Primary pointer down */
             Android_GetWindowCoordinates(x, y, &window_x, &window_y);
             /* send moved event */
-            SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
+            SDL_SendMouseMotion(Android_Window, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
             /* send mouse down event */
-            SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
+            SDL_SendMouseButton(Android_Window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
             pointerFingerID = fingerId;
         case ACTION_POINTER_DOWN:
             /* Non primary pointer down */
@@ -100,7 +100,7 @@
                 Android_GetWindowCoordinates(x, y, &window_x, &window_y);
 
                 /* send moved event */
-                SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
+                SDL_SendMouseMotion(Android_Window, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
             }
             SDL_SendTouchMotion(touchDeviceId, fingerId, x, y, p);
             break;
@@ -109,7 +109,7 @@
             /* Primary pointer up */
             /* send mouse up */
             pointerFingerID = (SDL_FingerID) 0;
-            SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
+            SDL_SendMouseButton(Android_Window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
         case ACTION_POINTER_UP:
             /* Non primary pointer up */
             SDL_SendTouch(touchDeviceId, fingerId, SDL_FALSE, x, y, p);