wayland-surface: Cleanup properly in _dispose
authorRobert Bragg <robert@linux.intel.com>
Mon, 9 Jan 2012 19:11:43 +0000 (19:11 +0000)
committerNeil Roberts <neil@linux.intel.com>
Thu, 1 Mar 2012 11:41:51 +0000 (11:41 +0000)
When disposing a ClutterWaylandSurface we now make sure to unref any
pipeline we created and unref any surface buffer textures we created.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
Reviewed-by: Emmanuele Bassi <ebassi@linux.intel.com>
clutter/wayland/clutter-wayland-surface.c

index 667f117..9a163cd 100644 (file)
@@ -169,11 +169,28 @@ clutter_wayland_surface_init (ClutterWaylandSurface *self)
 }
 
 static void
+free_surface_buffers (ClutterWaylandSurface *self)
+{
+  ClutterWaylandSurfacePrivate *priv = self->priv;
+
+  if (priv->buffer)
+    {
+      cogl_object_unref (priv->buffer);
+      priv->buffer = NULL;
+      free_pipeline (self);
+    }
+}
+
+static void
 clutter_wayland_surface_dispose (GObject *object)
 {
   ClutterWaylandSurface *self = CLUTTER_WAYLAND_SURFACE (object);
   ClutterWaylandSurfacePrivate *priv = self->priv;
 
+  free_pipeline (self);
+  free_surface_buffers (self);
+  priv->surface = NULL;
+
   G_OBJECT_CLASS (clutter_wayland_surface_parent_class)->dispose (object);
 }
 
@@ -424,19 +441,6 @@ clutter_wayland_surface_new (struct wl_surface *surface)
   return actor;
 }
 
-static void
-free_surface_buffers (ClutterWaylandSurface *self)
-{
-  ClutterWaylandSurfacePrivate *priv = self->priv;
-
-  if (priv->buffer)
-    {
-      cogl_object_unref (priv->buffer);
-      priv->buffer = NULL;
-      free_pipeline (self);
-    }
-}
-
 /**
  * clutter_wayland_surface_attach_buffer:
  * @self: A #ClutterWaylandSurface actor