[cogl-texture] Move the destruction of the material to _finalize

Otherwise if the dipose method is called twice the material will
already be destroyed when texture_free_gl_resources is called so it
will issue a warning about an invalid handle.
This commit is contained in:
Neil Roberts 2009-02-05 20:24:18 +00:00
parent 05c7e5a97c
commit a2168686b9

View File

@ -686,13 +686,22 @@ clutter_texture_dispose (GObject *object)
clutter_texture_async_load_cancel (texture); clutter_texture_async_load_cancel (texture);
G_OBJECT_CLASS (clutter_texture_parent_class)->dispose (object);
}
static void
clutter_texture_finalize (GObject *object)
{
ClutterTexture *texture = CLUTTER_TEXTURE (object);
ClutterTexturePrivate *priv;
if (priv->material != COGL_INVALID_HANDLE) if (priv->material != COGL_INVALID_HANDLE)
{ {
cogl_material_unref (priv->material); cogl_material_unref (priv->material);
priv->material = COGL_INVALID_HANDLE; priv->material = COGL_INVALID_HANDLE;
} }
G_OBJECT_CLASS (clutter_texture_parent_class)->dispose (object); G_OBJECT_CLASS (clutter_texture_parent_class)->finalize (object);
} }
static void static void
@ -847,6 +856,7 @@ clutter_texture_class_init (ClutterTextureClass *klass)
actor_class->allocate = clutter_texture_allocate; actor_class->allocate = clutter_texture_allocate;
gobject_class->dispose = clutter_texture_dispose; gobject_class->dispose = clutter_texture_dispose;
gobject_class->finalize = clutter_texture_finalize;
gobject_class->set_property = clutter_texture_set_property; gobject_class->set_property = clutter_texture_set_property;
gobject_class->get_property = clutter_texture_get_property; gobject_class->get_property = clutter_texture_get_property;