Android: minor preparation for bug 4142 (concurrency issues)
authorSylvain Becker <sylvain.becker@gmail.com>
Thu, 03 Jan 2019 13:38:33 +0100
changeset 12495219a154f54cb
parent 12494 6053ab61996a
child 12496 93771c30420b
Android: minor preparation for bug 4142 (concurrency issues)
src/video/android/SDL_androidwindow.c
     1.1 --- a/src/video/android/SDL_androidwindow.c	Thu Jan 03 13:14:16 2019 +0100
     1.2 +++ b/src/video/android/SDL_androidwindow.c	Thu Jan 03 13:38:33 2019 +0100
     1.3 @@ -40,9 +40,11 @@
     1.4  Android_CreateWindow(_THIS, SDL_Window * window)
     1.5  {
     1.6      SDL_WindowData *data;
     1.7 +    int retval = 0;
     1.8      
     1.9      if (Android_Window) {
    1.10 -        return SDL_SetError("Android only supports one window");
    1.11 +        retval = SDL_SetError("Android only supports one window");
    1.12 +        goto endfunction;
    1.13      }
    1.14      
    1.15      Android_PauseSem = SDL_CreateSemaphore(0);
    1.16 @@ -68,14 +70,16 @@
    1.17      
    1.18      data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data));
    1.19      if (!data) {
    1.20 -        return SDL_OutOfMemory();
    1.21 +        retval = SDL_OutOfMemory();
    1.22 +        goto endfunction;
    1.23      }
    1.24      
    1.25      data->native_window = Android_JNI_GetNativeWindow();
    1.26      
    1.27      if (!data->native_window) {
    1.28          SDL_free(data);
    1.29 -        return SDL_SetError("Could not fetch native window");
    1.30 +        retval = SDL_SetError("Could not fetch native window");
    1.31 +        goto endfunction;
    1.32      }
    1.33  
    1.34      /* Do not create EGLSurface for Vulkan window since it will then make the window
    1.35 @@ -86,14 +90,17 @@
    1.36          if (data->egl_surface == EGL_NO_SURFACE) {
    1.37              ANativeWindow_release(data->native_window);
    1.38              SDL_free(data);
    1.39 -            return SDL_SetError("Could not create GLES window surface");
    1.40 +            retval = SDL_SetError("Could not create GLES window surface");
    1.41 +            goto endfunction;
    1.42          }
    1.43      }
    1.44  
    1.45      window->driverdata = data;
    1.46      Android_Window = window;
    1.47 +
    1.48 +endfunction:
    1.49      
    1.50 -    return 0;
    1.51 +    return retval;
    1.52  }
    1.53  
    1.54  void
    1.55 @@ -139,9 +146,7 @@
    1.56  
    1.57  void
    1.58  Android_DestroyWindow(_THIS, SDL_Window *window)
    1.59 -{
    1.60 -    SDL_WindowData *data;
    1.61 -    
    1.62 +{ 
    1.63      if (window == Android_Window) {
    1.64          Android_Window = NULL;
    1.65          if (Android_PauseSem) SDL_DestroySemaphore(Android_PauseSem);
    1.66 @@ -149,8 +154,8 @@
    1.67          Android_PauseSem = NULL;
    1.68          Android_ResumeSem = NULL;
    1.69          
    1.70 -        if(window->driverdata) {
    1.71 -            data = (SDL_WindowData *) window->driverdata;
    1.72 +        if (window->driverdata) {
    1.73 +            SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
    1.74              if (data->egl_surface != EGL_NO_SURFACE) {
    1.75                  SDL_EGL_DestroySurface(_this, data->egl_surface);
    1.76              }