[mutter/wip/wayland] wayland: Handle the wayland buffer destroy callback



commit 8f4ef6a42f742ecae109f1d2d0faed5d9ef017c2
Author: Neil Roberts <neil linux intel com>
Date:   Mon Jan 30 18:35:15 2012 +0000

    wayland: Handle the wayland buffer destroy callback
    
    The notification from libwayland for when a buffer is destroyed was
    being ignored which meant that when we later tried to free the
    MetaWaylandBuffer struct we would prod into an invalid pointer and it
    would sometimes crash. This patch just makes it set the pointer to
    NULL in the destroy notification callback and then check for a NULL
    pointer in the free function.

 src/wayland/meta-wayland.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index 243e0c9..64a8b1c 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -128,6 +128,12 @@ buffer_destroy_callback (struct wl_listener *listener,
                          struct wl_resource *resource,
                          guint32 time)
 {
+  MetaWaylandBuffer *buffer =
+    container_of (listener, MetaWaylandBuffer,
+                  buffer_destroy_listener);
+
+  buffer->wayland_buffer = NULL;
+
   g_warning ("Buffer destroy callback");
 }
 
@@ -151,9 +157,12 @@ meta_wayland_buffer_free (MetaWaylandBuffer *buffer)
 {
   GList *l;
 
-  buffer->wayland_buffer->user_data = NULL;
+  if (buffer->wayland_buffer)
+    {
+      buffer->wayland_buffer->user_data = NULL;
 
-  wl_list_remove (&buffer->buffer_destroy_listener.link);
+      wl_list_remove (&buffer->buffer_destroy_listener.link);
+    }
 
   for (l = buffer->surfaces_attached_to; l; l = l->next)
     {



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