From: kgv Date: Tue, 29 Oct 2013 10:10:28 +0000 (+0400) Subject: 0024297: OpenGl_Texture::Release() might call OpenGL functions without active context X-Git-Tag: V6_7_0_beta~32 X-Git-Url: http://git.dev.opencascade.org/gitweb/?p=occt.git;a=commitdiff_plain;h=ec2eeb2dfa13177e27450013fdd9728c5dac412a 0024297: OpenGl_Texture::Release() might call OpenGL functions without active context Add check to Release() method of OpenGl_Texture, OpenGl_ShaderObject, OpenGl_ShaderProgram --- diff --git a/src/OpenGl/OpenGl_ShaderObject.cxx b/src/OpenGl/OpenGl_ShaderObject.cxx index 9537ccd070..e84c11a4ad 100644 --- a/src/OpenGl/OpenGl_ShaderObject.cxx +++ b/src/OpenGl/OpenGl_ShaderObject.cxx @@ -139,7 +139,8 @@ void OpenGl_ShaderObject::Release (const OpenGl_Context* theCtx) Standard_ASSERT_RETURN (theCtx != NULL, "OpenGl_ShaderObject destroyed without GL context! Possible GPU memory leakage...",); - if (theCtx->core20 != NULL) + if (theCtx->core20 != NULL + && theCtx->IsValid()) { theCtx->core20->glDeleteShader (myShaderID); } diff --git a/src/OpenGl/OpenGl_ShaderProgram.cxx b/src/OpenGl/OpenGl_ShaderProgram.cxx index 7a7ffcd646..6a6e5e1f66 100644 --- a/src/OpenGl/OpenGl_ShaderProgram.cxx +++ b/src/OpenGl/OpenGl_ShaderProgram.cxx @@ -1120,7 +1120,8 @@ void OpenGl_ShaderProgram::Release (const OpenGl_Context* theCtx) anIter.ChangeValue().Nullify(); } - if (theCtx->core20 != NULL) + if (theCtx->core20 != NULL + && theCtx->IsValid()) { theCtx->core20->glDeleteProgram (myProgramID); } diff --git a/src/OpenGl/OpenGl_Texture.cxx b/src/OpenGl/OpenGl_Texture.cxx index f1c1b9003b..2e9552c8d6 100644 --- a/src/OpenGl/OpenGl_Texture.cxx +++ b/src/OpenGl/OpenGl_Texture.cxx @@ -111,7 +111,10 @@ void OpenGl_Texture::Release (const OpenGl_Context* theGlCtx) Standard_ASSERT_RETURN (theGlCtx != NULL, "OpenGl_Texture destroyed without GL context! Possible GPU memory leakage...",); - glDeleteTextures (1, &myTextureId); + if (theGlCtx->IsValid()) + { + glDeleteTextures (1, &myTextureId); + } myTextureId = NO_TEXTURE; mySizeX = mySizeY = 0; }