Deleting program does not delete shaders that are marked

TRAC #12012 Also fixes failure to delete flagged program upon glUseProgram(0). Signed-off-by: Nicolas Capens Signed-off-by: Daniel Koch Author: Andrew Lewycky git-svn-id: https://angleproject.googlecode.com/svn/trunk@201 736b8ea6-26fd-11df-bfd4-992fa37f6226
parent feba9ba5
......@@ -550,12 +550,13 @@ void Context::useProgram(GLuint program)
{
Program *programObject = getCurrentProgram();
GLuint priorProgram = currentProgram;
currentProgram = program; // Must switch before trying to delete, otherwise it only gets flagged.
if (programObject && programObject->isFlaggedForDeletion())
{
deleteProgram(currentProgram);
deleteProgram(priorProgram);
}
currentProgram = program;
}
void Context::setFramebufferZero(Framebuffer *buffer)
......
......@@ -58,6 +58,16 @@ Program::Program()
Program::~Program()
{
unlink(true);
if (mVertexShader != NULL)
{
mVertexShader->detach();
}
if (mFragmentShader != NULL)
{
mFragmentShader->detach();
}
}
bool Program::attachShader(Shader *shader)
......
......@@ -185,6 +185,11 @@ void Shader::attach()
void Shader::detach()
{
mAttachCount--;
if (mAttachCount == 0 && mDeleteStatus)
{
getContext()->deleteShader(mHandle);
}
}
bool Shader::isAttached() const
......@@ -192,11 +197,6 @@ bool Shader::isAttached() const
return mAttachCount > 0;
}
bool Shader::isDeletable() const
{
return mDeleteStatus == true && mAttachCount == 0;
}
bool Shader::isFlaggedForDeletion() const
{
return mDeleteStatus;
......
......@@ -44,7 +44,6 @@ class Shader
void attach();
void detach();
bool isAttached() const;
bool isDeletable() const;
bool isFlaggedForDeletion() const;
void flagForDeletion();
......
......@@ -1346,11 +1346,6 @@ void __stdcall glDetachShader(GLuint program, GLuint shader)
{
return error(GL_INVALID_OPERATION);
}
if (shaderObject->isDeletable())
{
context->deleteShader(shader);
}
}
}
catch(std::bad_alloc&)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment