[libchamplain] Fix dispose of ChamplainView to really dispose the actors



commit 6b75604f2bc8d2eb729ac76e1ed5d3d31da44e7a
Author: JiÅ?í Techet <techet gmail com>
Date:   Wed Mar 23 01:46:03 2011 +0100

    Fix dispose of ChamplainView to really dispose the actors
    
    Also fix crash caused by ChamplainMarker destruction.

 champlain/champlain-marker-layer.c |    7 +---
 champlain/champlain-marker.h       |    1 -
 champlain/champlain-path-layer.c   |    3 --
 champlain/champlain-view.c         |   56 ++++++++++++++++-------------------
 4 files changed, 28 insertions(+), 39 deletions(-)
---
diff --git a/champlain/champlain-marker-layer.c b/champlain/champlain-marker-layer.c
index 150988c..12338fb 100644
--- a/champlain/champlain-marker-layer.c
+++ b/champlain/champlain-marker-layer.c
@@ -214,15 +214,12 @@ champlain_marker_layer_dispose (GObject *object)
   ChamplainMarkerLayer *self = CHAMPLAIN_MARKER_LAYER (object);
   ChamplainMarkerLayerPrivate *priv = self->priv;
 
-  champlain_marker_layer_remove_all (CHAMPLAIN_MARKER_LAYER (object));
-
   if (priv->view != NULL)
-    {
-      set_view (CHAMPLAIN_LAYER (self), NULL);
-    }
+    set_view (CHAMPLAIN_LAYER (self), NULL);
 
   if (priv->content_group)
     {
+      champlain_marker_layer_remove_all (CHAMPLAIN_MARKER_LAYER (object));
       clutter_actor_unparent (CLUTTER_ACTOR (priv->content_group));
       priv->content_group = NULL;
     }
diff --git a/champlain/champlain-marker.h b/champlain/champlain-marker.h
index 1565ee0..4f03375 100644
--- a/champlain/champlain-marker.h
+++ b/champlain/champlain-marker.h
@@ -89,7 +89,6 @@ void champlain_marker_animate_out (ChamplainMarker *marker);
 void champlain_marker_animate_out_with_delay (ChamplainMarker *marker,
     guint delay);
 
-
 void champlain_marker_set_selection_color (ClutterColor *color);
 const ClutterColor *champlain_marker_get_selection_color (void);
 
diff --git a/champlain/champlain-path-layer.c b/champlain/champlain-path-layer.c
index 2c791b0..a951856 100644
--- a/champlain/champlain-path-layer.c
+++ b/champlain/champlain-path-layer.c
@@ -511,9 +511,6 @@ add_node (ChamplainPathLayer *layer,
 {
   ChamplainPathLayerPrivate *priv = GET_PRIVATE (layer);
 
-  g_return_if_fail (CHAMPLAIN_IS_PATH_LAYER (layer));
-  g_return_if_fail (CHAMPLAIN_IS_LOCATION (location));
-
   g_signal_connect (G_OBJECT (location), "notify::latitude",
       G_CALLBACK (position_notify), layer);
 
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index c8a5930..f792918 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -135,6 +135,13 @@ typedef struct
 struct _ChamplainViewPrivate
 {
   ClutterActor *view_box;
+  ClutterActor *kinetic_scroll; /* Contains the viewport */
+  ClutterActor *viewport;  /* Contains the map_layer, license and markers */
+  ClutterActor *map_layer; /* Contains tiles actors (grouped by zoom level) */
+  ClutterActor *user_layers; /* Contains the markers */
+  ClutterActor *license_actor; /* Contains the license info */
+
+  ClutterLayoutManager *layout_manager;
 
   ChamplainMapSource *map_source; /* Current map tile source */
   gboolean kinetic_mode;
@@ -156,30 +163,20 @@ struct _ChamplainViewPrivate
   guint anchor_zoom_level; /* the zoom_level for which the current anchor has
                                 been computed for */
 
-  ClutterActor *kinetic_scroll; /* Contains the viewport */
-  ClutterActor *viewport;  /* Contains the map_layer, license and markers */
-  ClutterActor *map_layer; /* Contains tiles actors (grouped by zoom level) */
-
   gint viewport_x;
   gint viewport_y;
   gint viewport_width;
   gint viewport_height;
 
-  ClutterActor *user_layers; /* Contains the markers */
-
   gboolean keep_center_on_resize;
-
   gboolean zoom_on_double_click;
 
-  ClutterActor *license_actor; /* Contains the license info */
-
   ChamplainState state; /* View's global state */
 
   /* champlain_view_go_to's context, kept for stop_go_to */
   GoToContext *goto_context;
 
   gint tiles_loading;
-  ClutterLayoutManager *layout_manager;
 };
 
 G_DEFINE_TYPE (ChamplainView, champlain_view, CLUTTER_TYPE_ACTOR);
@@ -503,18 +500,15 @@ champlain_view_dispose (GObject *object)
   ChamplainView *view = CHAMPLAIN_VIEW (object);
   ChamplainViewPrivate *priv = view->priv;
 
-  if (priv->map_source != NULL)
+  if (priv->goto_context != NULL)
+    champlain_view_stop_go_to (view);
+
+  if (priv->update_viewport_timer != NULL)
     {
-      g_object_unref (priv->map_source);
-      priv->map_source = NULL;
+      g_timer_destroy (priv->update_viewport_timer);
+      priv->update_viewport_timer = NULL;
     }
 
-  if (priv->view_box != NULL)
-    priv->view_box = NULL;
-
-  if (priv->license_actor != NULL)
-    priv->license_actor = NULL;
-
   if (priv->kinetic_scroll != NULL)
     {
       champlain_kinetic_scroll_view_stop (CHAMPLAIN_KINETIC_SCROLL_VIEW (priv->kinetic_scroll));
@@ -527,21 +521,23 @@ champlain_view_dispose (GObject *object)
       priv->viewport = NULL;
     }
 
-  if (priv->map_layer != NULL)
-    priv->map_layer = NULL;
-
-  if (priv->user_layers != NULL)
-    priv->user_layers = NULL;
-
-  if (priv->goto_context != NULL)
-    champlain_view_stop_go_to (view);
+  if (priv->map_source != NULL)
+    {
+      g_object_unref (priv->map_source);
+      priv->map_source = NULL;
+    }
 
-  if (priv->update_viewport_timer != NULL)
+  if (priv->view_box != NULL)
     {
-      g_timer_destroy (priv->update_viewport_timer);
-      priv->update_viewport_timer = NULL;
+      clutter_actor_unparent (CLUTTER_ACTOR (priv->view_box));
+      priv->view_box = NULL;
     }
 
+  priv->map_layer = NULL;
+  priv->license_actor = NULL;
+  priv->user_layers = NULL;
+  priv->layout_manager = NULL;
+
   G_OBJECT_CLASS (champlain_view_parent_class)->dispose (object);
 }
 



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