[mutter] Take extra reference on the texture inside MutterWindow



commit 6b36e64e00376e43d6463c804d211501874b4621
Author: Tomas Frydrych <tf linux intel com>
Date:   Fri Aug 7 17:14:48 2009 +0100

    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).

 src/compositor/mutter-window.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/src/compositor/mutter-window.c b/src/compositor/mutter-window.c
index e1f7068..9761a41 100644
--- a/src/compositor/mutter-window.c
+++ b/src/compositor/mutter-window.c
@@ -362,6 +362,15 @@ mutter_window_constructed (GObject *object)
 
       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_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);
   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);
 }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]