Fixed crash initializing OpenGL ES renderer if OpenGL renderer fails
authorSam Lantinga <slouken@libsdl.org>
Sun, 22 Jun 2014 02:30:36 -0700
changeset 89051519c462cee6
parent 8904 c38e754cafd3
child 8906 c8da136e2a83
Fixed crash initializing OpenGL ES renderer if OpenGL renderer fails
src/video/SDL_video.c
src/video/cocoa/SDL_cocoawindow.m
src/video/uikit/SDL_uikitwindow.m
src/video/windows/SDL_windowswindow.c
src/video/x11/SDL_x11window.c
     1.1 --- a/src/video/SDL_video.c	Sat Jun 21 21:46:42 2014 -0700
     1.2 +++ b/src/video/SDL_video.c	Sun Jun 22 02:30:36 2014 -0700
     1.3 @@ -1402,7 +1402,7 @@
     1.4  
     1.5      if (_this->CreateWindow && !(flags & SDL_WINDOW_FOREIGN)) {
     1.6          if (_this->CreateWindow(_this, window) < 0) {
     1.7 -            if (flags & SDL_WINDOW_OPENGL) {
     1.8 +            if ((flags & SDL_WINDOW_OPENGL) && !(window->flags & SDL_WINDOW_OPENGL)) {
     1.9                  SDL_GL_UnloadLibrary();
    1.10              }
    1.11              return -1;
     2.1 --- a/src/video/cocoa/SDL_cocoawindow.m	Sat Jun 21 21:46:42 2014 -0700
     2.2 +++ b/src/video/cocoa/SDL_cocoawindow.m	Sun Jun 22 02:30:36 2014 -0700
     2.3 @@ -1488,6 +1488,8 @@
     2.4      NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
     2.5      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     2.6  
     2.7 +    window->driverdata = NULL;
     2.8 +
     2.9      if (data) {
    2.10          [data->listener close];
    2.11          [data->listener release];
     3.1 --- a/src/video/uikit/SDL_uikitwindow.m	Sat Jun 21 21:46:42 2014 -0700
     3.2 +++ b/src/video/uikit/SDL_uikitwindow.m	Sun Jun 22 02:30:36 2014 -0700
     3.3 @@ -289,11 +289,13 @@
     3.4  UIKit_DestroyWindow(_THIS, SDL_Window * window)
     3.5  {
     3.6      SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
     3.7 +
     3.8 +    window->driverdata = NULL;
     3.9 +
    3.10      if (data) {
    3.11          [data->viewcontroller release];
    3.12          [data->uiwindow release];
    3.13          SDL_free(data);
    3.14 -        window->driverdata = NULL;
    3.15      }
    3.16  }
    3.17  
     4.1 --- a/src/video/windows/SDL_windowswindow.c	Sat Jun 21 21:46:42 2014 -0700
     4.2 +++ b/src/video/windows/SDL_windowswindow.c	Sun Jun 22 02:30:36 2014 -0700
     4.3 @@ -619,6 +619,8 @@
     4.4  {
     4.5      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     4.6  
     4.7 +    window->driverdata = NULL;
     4.8 +
     4.9      if (data) {
    4.10          ReleaseDC(data->hwnd, data->hdc);
    4.11          if (data->created) {
     5.1 --- a/src/video/x11/SDL_x11window.c	Sat Jun 21 21:46:42 2014 -0700
     5.2 +++ b/src/video/x11/SDL_x11window.c	Sun Jun 22 02:30:36 2014 -0700
     5.3 @@ -1393,6 +1393,7 @@
     5.4  X11_DestroyWindow(_THIS, SDL_Window * window)
     5.5  {
     5.6      SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
     5.7 +
     5.8      window->driverdata = NULL;
     5.9  
    5.10      if (data) {