Take extra reference on the texture inside MutterWindow

We store a pointer to the texture independently of the ClutterContainer
internals, and rely on the pointer remaining valid until we run dispose.
Since we also provide public API to access this pointer, we should not
rely on the reference ClutterContainer holds to ensure that texture will
not be destroyed (e.g., some nasty developer could reparent the texture).
This commit is contained in:
Tomas Frydrych 2009-08-07 17:14:48 +01:00
parent 84059f1faa
commit 6b36e64e00

View File

@ -362,6 +362,15 @@ mutter_window_constructed (GObject *object)
clutter_container_add_actor (CLUTTER_CONTAINER (self), priv->actor); clutter_container_add_actor (CLUTTER_CONTAINER (self), priv->actor);
/*
* Since we are holding a pointer to this actor independently of the
* ClutterContainer internals, and provide a public API to access it,
* add a reference here, so that if someone is messing about with us
* via the container interface, we do not end up with a dangling pointer.
* We will release it in dispose().
*/
g_object_ref (priv->actor);
g_signal_connect (priv->window, "notify::decorated", g_signal_connect (priv->window, "notify::decorated",
G_CALLBACK (mutter_meta_window_decorated_notify), self); G_CALLBACK (mutter_meta_window_decorated_notify), self);
} }
@ -415,6 +424,12 @@ mutter_window_dispose (GObject *object)
info->windows = g_list_remove (info->windows, (gconstpointer) self); info->windows = g_list_remove (info->windows, (gconstpointer) self);
g_hash_table_remove (info->windows_by_xid, (gpointer) priv->xwindow); g_hash_table_remove (info->windows_by_xid, (gpointer) priv->xwindow);
/*
* Release the extra reference we took on the actor.
*/
g_object_unref (priv->actor);
priv->actor = NULL;
G_OBJECT_CLASS (mutter_window_parent_class)->dispose (object); G_OBJECT_CLASS (mutter_window_parent_class)->dispose (object);
} }