Fixed crash initializing OpenGL ES renderer if OpenGL renderer fails
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c
index 2a6de10..2e097d0 100644
--- a/src/video/SDL_video.c
+++ b/src/video/SDL_video.c
@@ -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;
diff --git a/src/video/cocoa/SDL_cocoawindow.m b/src/video/cocoa/SDL_cocoawindow.m
index 71f7bb6..e9364d8 100644
--- a/src/video/cocoa/SDL_cocoawindow.m
+++ b/src/video/cocoa/SDL_cocoawindow.m
@@ -1488,6 +1488,8 @@ Cocoa_DestroyWindow(_THIS, SDL_Window * window)
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+ window->driverdata = NULL;
+
if (data) {
[data->listener close];
[data->listener release];
diff --git a/src/video/uikit/SDL_uikitwindow.m b/src/video/uikit/SDL_uikitwindow.m
index a805227..b6c1a0d 100644
--- a/src/video/uikit/SDL_uikitwindow.m
+++ b/src/video/uikit/SDL_uikitwindow.m
@@ -289,11 +289,13 @@ void
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;
}
}
diff --git a/src/video/windows/SDL_windowswindow.c b/src/video/windows/SDL_windowswindow.c
index 8ff85a3..0cbfe78 100644
--- a/src/video/windows/SDL_windowswindow.c
+++ b/src/video/windows/SDL_windowswindow.c
@@ -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) {
diff --git a/src/video/x11/SDL_x11window.c b/src/video/x11/SDL_x11window.c
index 5c5bdd6..2eccd27 100644
--- a/src/video/x11/SDL_x11window.c
+++ b/src/video/x11/SDL_x11window.c
@@ -1393,6 +1393,7 @@ void
X11_DestroyWindow(_THIS, SDL_Window * window)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
+
window->driverdata = NULL;
if (data) {