mesa: Prevent repeated glDeleteProgram() from blowing away our refcounts.
authorEric Anholt <eric@anholt.net>
Tue, 4 Oct 2011 22:36:15 +0000 (15:36 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 10 Oct 2011 18:38:52 +0000 (11:38 -0700)
glDeleteProgram should only be able to remove the one refcount for the
user's reference to the program from the hash table (even though that
ref does live on in the hash table until the last other ref is
removed).

Fixes piglit ARB_shader_objects/delete-repeat.

Reviewed-by: Chad Versace <chad@chad-versace.us>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
src/mesa/main/shaderapi.c

index c3aabe43f8b21c08c1b7dd36d63a3a4ba5fe2f2a..6868dfab09ee90fbab320e8728bf3570f01a5d7b 100644 (file)
@@ -390,10 +390,12 @@ delete_shader_program(struct gl_context *ctx, GLuint name)
    if (!shProg)
       return;
 
-   shProg->DeletePending = GL_TRUE;
+   if (!shProg->DeletePending) {
+      shProg->DeletePending = GL_TRUE;
 
-   /* effectively, decr shProg's refcount */
-   _mesa_reference_shader_program(ctx, &shProg, NULL);
+      /* effectively, decr shProg's refcount */
+      _mesa_reference_shader_program(ctx, &shProg, NULL);
+   }
 }