Fixed crash initializing OpenGL ES renderer if OpenGL renderer fails

main
Sam Lantinga 2014-06-22 02:30:36 -07:00
parent 5df11f8aa1
commit b7b6d8ab7a
5 changed files with 9 additions and 2 deletions

View File

@ -1402,7 +1402,7 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)
if (_this->CreateWindow && !(flags & SDL_WINDOW_FOREIGN)) { if (_this->CreateWindow && !(flags & SDL_WINDOW_FOREIGN)) {
if (_this->CreateWindow(_this, window) < 0) { if (_this->CreateWindow(_this, window) < 0) {
if (flags & SDL_WINDOW_OPENGL) { if ((flags & SDL_WINDOW_OPENGL) && !(window->flags & SDL_WINDOW_OPENGL)) {
SDL_GL_UnloadLibrary(); SDL_GL_UnloadLibrary();
} }
return -1; return -1;

View File

@ -1488,6 +1488,8 @@ Cocoa_DestroyWindow(_THIS, SDL_Window * window)
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
window->driverdata = NULL;
if (data) { if (data) {
[data->listener close]; [data->listener close];
[data->listener release]; [data->listener release];

View File

@ -289,11 +289,13 @@ void
UIKit_DestroyWindow(_THIS, SDL_Window * window) UIKit_DestroyWindow(_THIS, SDL_Window * window)
{ {
SDL_WindowData *data = (SDL_WindowData *)window->driverdata; SDL_WindowData *data = (SDL_WindowData *)window->driverdata;
window->driverdata = NULL;
if (data) { if (data) {
[data->viewcontroller release]; [data->viewcontroller release];
[data->uiwindow release]; [data->uiwindow release];
SDL_free(data); SDL_free(data);
window->driverdata = NULL;
} }
} }

View File

@ -619,6 +619,8 @@ WIN_DestroyWindow(_THIS, SDL_Window * window)
{ {
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
window->driverdata = NULL;
if (data) { if (data) {
ReleaseDC(data->hwnd, data->hdc); ReleaseDC(data->hwnd, data->hdc);
if (data->created) { if (data->created) {

View File

@ -1393,6 +1393,7 @@ void
X11_DestroyWindow(_THIS, SDL_Window * window) X11_DestroyWindow(_THIS, SDL_Window * window)
{ {
SDL_WindowData *data = (SDL_WindowData *) window->driverdata; SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
window->driverdata = NULL; window->driverdata = NULL;
if (data) { if (data) {