From 4b59abfd9546addc0c6e119a3b0935aec0fb39bf Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 12 Jul 2013 23:28:34 -0700 Subject: [PATCH] Don't set the current OpenGL window if the context creation fails. --- src/video/SDL_video.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 40060237e..988d49c3f 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -2739,11 +2739,12 @@ SDL_GL_CreateContext(SDL_Window * window) 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; }