Skip to content

Commit

Permalink
Fixed crash initializing OpenGL ES renderer if OpenGL renderer fails
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jun 22, 2014
1 parent 5df11f8 commit b7b6d8a
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/video/SDL_video.c
Expand Up @@ -1402,7 +1402,7 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags)

if (_this->CreateWindow && !(flags & SDL_WINDOW_FOREIGN)) {
if (_this->CreateWindow(_this, window) < 0) {
if (flags & SDL_WINDOW_OPENGL) {
if ((flags & SDL_WINDOW_OPENGL) && !(window->flags & SDL_WINDOW_OPENGL)) {
SDL_GL_UnloadLibrary();
}
return -1;
Expand Down
2 changes: 2 additions & 0 deletions src/video/cocoa/SDL_cocoawindow.m
Expand Up @@ -1488,6 +1488,8 @@ - (void)resetCursorRects
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;

window->driverdata = NULL;

if (data) {
[data->listener close];
[data->listener release];
Expand Down
4 changes: 3 additions & 1 deletion src/video/uikit/SDL_uikitwindow.m
Expand Up @@ -289,11 +289,13 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo
UIKit_DestroyWindow(_THIS, SDL_Window * window)
{
SDL_WindowData *data = (SDL_WindowData *)window->driverdata;

window->driverdata = NULL;

if (data) {
[data->viewcontroller release];
[data->uiwindow release];
SDL_free(data);
window->driverdata = NULL;
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/video/windows/SDL_windowswindow.c
Expand Up @@ -619,6 +619,8 @@ WIN_DestroyWindow(_THIS, SDL_Window * window)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;

window->driverdata = NULL;

if (data) {
ReleaseDC(data->hwnd, data->hdc);
if (data->created) {
Expand Down
1 change: 1 addition & 0 deletions src/video/x11/SDL_x11window.c
Expand Up @@ -1393,6 +1393,7 @@ void
X11_DestroyWindow(_THIS, SDL_Window * window)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;

window->driverdata = NULL;

if (data) {
Expand Down

0 comments on commit b7b6d8a

Please sign in to comment.