1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-05-21 10:55:33 +03:00

0024297: OpenGl_Texture::Release() might call OpenGL functions without active context

Add check to Release() method of OpenGl_Texture, OpenGl_ShaderObject, OpenGl_ShaderProgram
This commit is contained in:
kgv 2013-10-29 14:10:28 +04:00 committed by bugmaster
parent d0cc1cb7e0
commit ec2eeb2dfa
3 changed files with 8 additions and 3 deletions

View File

@ -139,7 +139,8 @@ void OpenGl_ShaderObject::Release (const OpenGl_Context* theCtx)
Standard_ASSERT_RETURN (theCtx != NULL, Standard_ASSERT_RETURN (theCtx != NULL,
"OpenGl_ShaderObject destroyed without GL context! Possible GPU memory leakage...",); "OpenGl_ShaderObject destroyed without GL context! Possible GPU memory leakage...",);
if (theCtx->core20 != NULL) if (theCtx->core20 != NULL
&& theCtx->IsValid())
{ {
theCtx->core20->glDeleteShader (myShaderID); theCtx->core20->glDeleteShader (myShaderID);
} }

View File

@ -1120,7 +1120,8 @@ void OpenGl_ShaderProgram::Release (const OpenGl_Context* theCtx)
anIter.ChangeValue().Nullify(); anIter.ChangeValue().Nullify();
} }
if (theCtx->core20 != NULL) if (theCtx->core20 != NULL
&& theCtx->IsValid())
{ {
theCtx->core20->glDeleteProgram (myProgramID); theCtx->core20->glDeleteProgram (myProgramID);
} }

View File

@ -111,7 +111,10 @@ void OpenGl_Texture::Release (const OpenGl_Context* theGlCtx)
Standard_ASSERT_RETURN (theGlCtx != NULL, Standard_ASSERT_RETURN (theGlCtx != NULL,
"OpenGl_Texture destroyed without GL context! Possible GPU memory leakage...",); "OpenGl_Texture destroyed without GL context! Possible GPU memory leakage...",);
glDeleteTextures (1, &myTextureId); if (theGlCtx->IsValid())
{
glDeleteTextures (1, &myTextureId);
}
myTextureId = NO_TEXTURE; myTextureId = NO_TEXTURE;
mySizeX = mySizeY = 0; mySizeX = mySizeY = 0;
} }