[mutter] MetaSurfaceActorWayland: Use weak pointer instead of destroy hook



commit 19f7e310d948d71a6b95ab5cfd12c1335b1fbddc
Author: Jonas Ådahl <jadahl gmail com>
Date:   Mon Jan 18 16:59:45 2016 +0800

    MetaSurfaceActorWayland: Use weak pointer instead of destroy hook
    
    MetaWaylandSurface is a GObject now, so lets utilize that.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763431

 src/compositor/meta-surface-actor-wayland.c |   29 +++++++++++++--------------
 src/wayland/meta-wayland-surface.c          |    3 --
 2 files changed, 14 insertions(+), 18 deletions(-)
---
diff --git a/src/compositor/meta-surface-actor-wayland.c b/src/compositor/meta-surface-actor-wayland.c
index 1050fc7..33036d8 100644
--- a/src/compositor/meta-surface-actor-wayland.c
+++ b/src/compositor/meta-surface-actor-wayland.c
@@ -402,8 +402,20 @@ static void
 meta_surface_actor_wayland_dispose (GObject *object)
 {
   MetaSurfaceActorWayland *self = META_SURFACE_ACTOR_WAYLAND (object);
+  MetaSurfaceActorWaylandPrivate *priv =
+    meta_surface_actor_wayland_get_instance_private (self);
+  MetaWaylandFrameCallback *cb, *next;
 
   meta_surface_actor_wayland_set_texture (self, NULL);
+  if (priv->surface)
+    {
+      g_object_remove_weak_pointer (G_OBJECT (priv->surface),
+                                    (gpointer *) &priv->surface);
+      priv->surface = NULL;
+    }
+
+  wl_list_for_each_safe (cb, next, &priv->frame_callback_list, link)
+    wl_resource_destroy (cb->resource);
 
   G_OBJECT_CLASS (meta_surface_actor_wayland_parent_class)->dispose (object);
 }
@@ -454,6 +466,8 @@ meta_surface_actor_wayland_new (MetaWaylandSurface *surface)
 
   wl_list_init (&priv->frame_callback_list);
   priv->surface = surface;
+  g_object_add_weak_pointer (G_OBJECT (priv->surface),
+                             (gpointer *) &priv->surface);
 
   return META_SURFACE_ACTOR (self);
 }
@@ -472,18 +486,3 @@ meta_surface_actor_wayland_get_surface (MetaSurfaceActorWayland *self)
   MetaSurfaceActorWaylandPrivate *priv = meta_surface_actor_wayland_get_instance_private (self);
   return priv->surface;
 }
-
-void
-meta_surface_actor_wayland_surface_destroyed (MetaSurfaceActorWayland *self)
-{
-  MetaWaylandFrameCallback *callback, *next;
-  MetaSurfaceActorWaylandPrivate *priv =
-    meta_surface_actor_wayland_get_instance_private (self);
-
-  wl_list_for_each_safe (callback, next, &priv->frame_callback_list, link)
-    {
-      wl_resource_destroy (callback->resource);
-    }
-
-  priv->surface = NULL;
-}
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index e52d17f..b66dd94 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -1134,9 +1134,6 @@ wl_surface_destructor (struct wl_resource *resource)
   if (surface->input_region)
     cairo_region_destroy (surface->input_region);
 
-  meta_surface_actor_wayland_surface_destroyed (
-    META_SURFACE_ACTOR_WAYLAND (surface->surface_actor));
-
   g_object_unref (surface->surface_actor);
 
   meta_wayland_compositor_destroy_frame_callbacks (compositor, surface);


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