[Cogl] [PATCH 1/4] cogland: Fix handling the destroy listener for the pending buffer

Neil Roberts neil at linux.intel.com
Thu Apr 11 09:11:13 PDT 2013


The handler for the destroy signal on the pending buffer was not
correctly being removed if the same buffer is committed twice to the
surface. It was also not being cleared if the surface is destroyed
before the pending buffer is committed.
---
 examples/cogland.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/examples/cogland.c b/examples/cogland.c
index d09c319..d9efa37 100644
--- a/examples/cogland.c
+++ b/examples/cogland.c
@@ -546,10 +546,13 @@ cogland_surface_commit (struct wl_client *client,
 
           wl_signal_add (&surface->buffer->resource.destroy_signal,
                          &surface->buffer_destroy_listener);
-          wl_list_remove (&surface->pending.buffer_destroy_listener.link);
         }
     }
-  surface->pending.buffer = NULL;
+  if (surface->pending.buffer)
+    {
+      wl_list_remove (&surface->pending.buffer_destroy_listener.link);
+      surface->pending.buffer = NULL;
+    }
   surface->pending.sx = 0;
   surface->pending.sy = 0;
 
@@ -614,6 +617,9 @@ cogland_surface_free (CoglandSurface *surface)
   compositor->surfaces = g_list_remove (compositor->surfaces, surface);
   cogland_surface_detach_buffer_and_notify (surface);
 
+  if (surface->pending.buffer)
+    wl_list_remove (&surface->pending.buffer_destroy_listener.link);
+
   wl_list_for_each_safe (cb, next,
                          &surface->pending.frame_callback_list, link)
     wl_resource_destroy (&cb->resource);
-- 
1.7.11.3.g3c3efa5



More information about the Cogl mailing list