Don't set the current OpenGL window if the context creation fails.
authorSam Lantinga <slouken@libsdl.org>
Fri, 12 Jul 2013 23:28:34 -0700
changeset 7429 ff7edbf76a73
parent 7428 9fb919fc2dd3
child 7430 f204394628db
Don't set the current OpenGL window if the context creation fails.
src/video/SDL_video.c
--- a/src/video/SDL_video.c	Fri Jul 12 23:16:11 2013 -0700
+++ b/src/video/SDL_video.c	Fri Jul 12 23:28:34 2013 -0700
@@ -2739,11 +2739,12 @@
     ctx = _this->GL_CreateContext(_this, window);
 
     /* Creating a context is assumed to make it current in the SDL driver. */
-    _this->current_glwin = window;
-    _this->current_glctx = ctx;
-    SDL_TLSSet(_this->current_glwin_tls, window, NULL);
-    SDL_TLSSet(_this->current_glctx_tls, ctx, NULL);
-
+    if (ctx) {
+        _this->current_glwin = window;
+        _this->current_glctx = ctx;
+        SDL_TLSSet(_this->current_glwin_tls, window, NULL);
+        SDL_TLSSet(_this->current_glctx_tls, ctx, NULL);
+    }
     return ctx;
 }