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 8963f94215b55583
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
     1.1 --- a/src/events/SDL_mouse.c	Sat Jun 28 12:17:29 2014 -0300
     1.2 +++ b/src/events/SDL_mouse.c	Sat Jun 28 12:36:44 2014 -0300
     1.3 @@ -142,7 +142,7 @@
     1.4      SDL_Mouse *mouse = SDL_GetMouse();
     1.5      SDL_bool inWindow = SDL_TRUE;
     1.6  
     1.7 -    if ((window->flags & SDL_WINDOW_MOUSE_CAPTURE) == 0) {
     1.8 +    if (window != NULL && ((window->flags & SDL_WINDOW_MOUSE_CAPTURE) == 0)) {
     1.9          int w, h;
    1.10          SDL_GetWindowSize(window, &w, &h);
    1.11          if (x < 0 || y < 0 || x >= w || y >= h) {
     2.1 --- a/src/video/android/SDL_androidtouch.c	Sat Jun 28 12:17:29 2014 -0300
     2.2 +++ b/src/video/android/SDL_androidtouch.c	Sat Jun 28 12:36:44 2014 -0300
     2.3 @@ -86,9 +86,9 @@
     2.4              /* Primary pointer down */
     2.5              Android_GetWindowCoordinates(x, y, &window_x, &window_y);
     2.6              /* send moved event */
     2.7 -            SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
     2.8 +            SDL_SendMouseMotion(Android_Window, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
     2.9              /* send mouse down event */
    2.10 -            SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
    2.11 +            SDL_SendMouseButton(Android_Window, SDL_TOUCH_MOUSEID, SDL_PRESSED, SDL_BUTTON_LEFT);
    2.12              pointerFingerID = fingerId;
    2.13          case ACTION_POINTER_DOWN:
    2.14              /* Non primary pointer down */
    2.15 @@ -100,7 +100,7 @@
    2.16                  Android_GetWindowCoordinates(x, y, &window_x, &window_y);
    2.17  
    2.18                  /* send moved event */
    2.19 -                SDL_SendMouseMotion(NULL, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
    2.20 +                SDL_SendMouseMotion(Android_Window, SDL_TOUCH_MOUSEID, 0, window_x, window_y);
    2.21              }
    2.22              SDL_SendTouchMotion(touchDeviceId, fingerId, x, y, p);
    2.23              break;
    2.24 @@ -109,7 +109,7 @@
    2.25              /* Primary pointer up */
    2.26              /* send mouse up */
    2.27              pointerFingerID = (SDL_FingerID) 0;
    2.28 -            SDL_SendMouseButton(NULL, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
    2.29 +            SDL_SendMouseButton(Android_Window, SDL_TOUCH_MOUSEID, SDL_RELEASED, SDL_BUTTON_LEFT);
    2.30          case ACTION_POINTER_UP:
    2.31              /* Non primary pointer up */
    2.32              SDL_SendTouch(touchDeviceId, fingerId, SDL_FALSE, x, y, p);