[libchamplain] set all priv vars to NULL after unref in dispose



commit a1bb52d126bcf7a33325677538299ee95da4abe6
Author: Simon Wenner <simon wenner ch>
Date:   Mon Aug 10 21:20:33 2009 +0200

    set all priv vars to NULL after unref in dispose

 champlain/champlain-local-map-data-source.c   |    6 +++++-
 champlain/champlain-memphis-map-source.c      |   25 +++++++++++++++++++------
 champlain/champlain-network-map-data-source.c |   10 ++++++++--
 3 files changed, 32 insertions(+), 9 deletions(-)
---
diff --git a/champlain/champlain-local-map-data-source.c b/champlain/champlain-local-map-data-source.c
index 3d5b566..381ff83 100644
--- a/champlain/champlain-local-map-data-source.c
+++ b/champlain/champlain-local-map-data-source.c
@@ -78,7 +78,11 @@ champlain_local_map_data_source_dispose (GObject *object)
   ChamplainLocalMapDataSource *self = (ChamplainLocalMapDataSource *) object;
   ChamplainLocalMapDataSourcePrivate *priv = GET_PRIVATE(self);
 
-  memphis_map_free (priv->map);
+  if (priv->map)
+    {
+      memphis_map_free (priv->map);
+      priv->map = NULL;
+    }
 
   G_OBJECT_CLASS (champlain_local_map_data_source_parent_class)->dispose (object);
 }
diff --git a/champlain/champlain-memphis-map-source.c b/champlain/champlain-memphis-map-source.c
index 7377616..d85e8fc 100644
--- a/champlain/champlain-memphis-map-source.c
+++ b/champlain/champlain-memphis-map-source.c
@@ -157,12 +157,25 @@ champlain_memphis_map_source_dispose (GObject *object)
   ChamplainMemphisMapSourcePrivate *priv = GET_PRIVATE(self);
 
   if (priv->thpool)
-    g_thread_pool_free (priv->thpool, FALSE, TRUE);
-
+    {
+      g_thread_pool_free (priv->thpool, FALSE, TRUE);
+      priv->thpool = NULL;
+    }
   if (priv->map_data_source)
-    g_object_unref (priv->map_data_source);
-  memphis_renderer_free (priv->renderer);
-  memphis_rule_set_free (priv->rules);
+    {
+      g_object_unref (priv->map_data_source);
+      priv->map_data_source = NULL;
+    }
+  if (priv->renderer)
+    {
+      memphis_renderer_free (priv->renderer);
+      priv->renderer = NULL;
+    }
+  if (priv->rules)
+    {
+      memphis_rule_set_free (priv->rules);
+      priv->rules = NULL;
+    }
 
   G_OBJECT_CLASS (champlain_memphis_map_source_parent_class)->dispose (object);
 }
@@ -777,7 +790,7 @@ champlain_memphis_map_source_get_rule (ChamplainMemphisMapSource *self,
  * champlain_memphis_map_source_get_rule_ids:
  * @map_source: a #ChamplainMemphisMapSource
  *
- * Returns a #GList if id strings of the form:
+ * Returns a #GList of id strings of the form:
  * key1|key2|...|keyN:value1|value2|...|valueM
  *
  * Example: "waterway:river|stream|canal"
diff --git a/champlain/champlain-network-map-data-source.c b/champlain/champlain-network-map-data-source.c
index 7398549..7e90d4b 100644
--- a/champlain/champlain-network-map-data-source.c
+++ b/champlain/champlain-network-map-data-source.c
@@ -126,10 +126,16 @@ champlain_network_map_data_source_dispose (GObject *object)
   ChamplainNetworkMapDataSourcePrivate *priv = GET_PRIVATE (self);
 
   if (priv->map)
-    memphis_map_free (priv->map);
+    {
+      memphis_map_free (priv->map);
+      priv->map = NULL;
+    }
 
   if (soup_session != NULL)
-    soup_session_abort (soup_session);
+    {
+      soup_session_abort (soup_session);
+      soup_session = NULL;
+    }
 
   G_OBJECT_CLASS (champlain_network_map_data_source_parent_class)->dispose (object);
 }



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