[mutter/wip/wayland] wayland: Track surface->actor as a weak pointer



commit bd773775abcb123728a9ad3514819ac171791f1c
Author: Robert Bragg <robert linux intel com>
Date:   Wed Jan 18 19:24:13 2012 +0000

    wayland: Track surface->actor as a weak pointer
    
    This marks surface->actor as a weak pointer so that we can gracefully
    handle the actor being destroyed if the corresponding MetaWindow becomes
    unmanaged.

 src/wayland/meta-wayland.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
---
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index 861f77f..5eedb82 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -401,6 +401,10 @@ meta_wayland_surface_free (MetaWaylandSurface *surface)
       clutter_actor_destroy (surface->actor);
     }
 
+  if (surface->actor)
+    g_object_remove_weak_pointer (G_OBJECT (surface->actor),
+                                  (void **)&surface->actor);
+
   g_slice_free (MetaWaylandSurface, surface);
 
   meta_wayland_compositor_repick (compositor);
@@ -983,6 +987,11 @@ xserver_set_window_id (struct wl_client *client,
 
       surface->actor = surface_actor;
 
+      /* If the MetaWindow becomes unmanaged (surface->actor will be freed
+       * in this case) we need to make sure to clear our pointer. */
+      g_object_add_weak_pointer (G_OBJECT (surface->actor),
+                                 (void **)&surface->actor);
+
 #if 0
       if (window->visible_to_compositor)
         meta_compositor_show_window (display->compositor, window,



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