material: Check before unreferencing a texture
authorEmmanuele Bassi <ebassi@linux.intel.com>
Mon, 6 Sep 2010 17:07:07 +0000 (18:07 +0100)
committerEmmanuele Bassi <ebassi@linux.intel.com>
Mon, 6 Sep 2010 17:09:19 +0000 (18:09 +0100)
When disposing a material layer of type 'texture' we should check that
the texture handle is still valid before calling cogl_handle_unref().
This avoids an assertion failure when disposing a ClutterTexture.

clutter/cogl/cogl/cogl-material.c

index b21f431..f4936bf 100644 (file)
@@ -4457,7 +4457,8 @@ _cogl_material_layer_free (CoglMaterialLayer *layer)
         }
     }
 
-  if (layer->differences & COGL_MATERIAL_LAYER_STATE_TEXTURE)
+  if (layer->differences & COGL_MATERIAL_LAYER_STATE_TEXTURE &&
+      layer->texture != COGL_INVALID_HANDLE)
     cogl_handle_unref (layer->texture);
 
   if (layer->differences & COGL_MATERIAL_LAYER_STATE_NEEDS_BIG_STATE)