From 6c47fc8322ab0378be6d19a76dccf3bc59a420ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Wed, 31 Oct 2007 16:28:59 +0000 Subject: [PATCH] Before destroying a current context, set some other current context (even none). Fixes crashes with Intel. svn path=/trunk/KDE/kdebase/workspace/; revision=731410 --- compositingprefs.cpp | 15 +++++---------- scene_opengl.cpp | 4 +++- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/compositingprefs.cpp b/compositingprefs.cpp index df9266ae7b..3584e10cae 100644 --- a/compositingprefs.cpp +++ b/compositingprefs.cpp @@ -76,9 +76,7 @@ void CompositingPrefs::detect() GLXDrawable olddrawable = glXGetCurrentDrawable(); GLXDrawable oldreaddrawable; if( hasglx13 ) - { oldreaddrawable = glXGetCurrentReadDrawable(); - } if( createGLXContext() ) { @@ -87,17 +85,14 @@ void CompositingPrefs::detect() deleteGLXContext(); } - if( oldcontext != NULL ) - { - if( hasglx13 ) + if( hasglx13 ) { - glXMakeContextCurrent( display(), olddrawable, oldreaddrawable, oldcontext ); + glXMakeContextCurrent( display(), olddrawable, oldreaddrawable, oldcontext ); } - else + else { - glXMakeCurrent( display(), olddrawable, oldcontext ); + glXMakeCurrent( display(), olddrawable, oldcontext ); } - } #endif } @@ -201,7 +196,7 @@ void CompositingPrefs::applyDriverSpecificOptions() mEnableCompositing = true; mStrictBinding = false; } - else if( mDriver == "intel") + else if( mDriver == "intel" ) { kDebug() << "intel driver, disabling vsync, enabling direct"; mEnableVSync = false; diff --git a/scene_opengl.cpp b/scene_opengl.cpp index f2d3d28c60..239fd26552 100644 --- a/scene_opengl.cpp +++ b/scene_opengl.cpp @@ -189,6 +189,7 @@ SceneOpenGL::~SceneOpenGL() glXDestroyPixmap( display(), last_pixmap ); glXDestroyContext( display(), ctxdrawable ); } + glXMakeCurrent( display(), None, NULL ); glXDestroyContext( display(), ctxbuffer ); checkGLError( "Cleanup" ); } @@ -297,10 +298,11 @@ bool SceneOpenGL::initRenderingContext() kDebug( 1212 ) << "Couldn't initialize rendering context"; return false; } + glXMakeCurrent( display(), None, NULL ); glXDestroyContext( display(), ctxbuffer ); direct_rendering = false; // try again ctxbuffer = glXCreateNewContext( display(), fbcbuffer, GLX_RGBA_TYPE, NULL, GL_FALSE ); - if( ctxbuffer == NULL || !glXMakeCurrent( display(), glxbuffer, ctxbuffer )) + if( ctxbuffer == NULL || !glXMakeCurrent( display(), glxbuffer, ctxbuffer ) || errs.error( true )) { kDebug( 1212 ) << "Couldn't initialize rendering context"; return false;