[libchamplain] Call g_object_ref() on data passed to idle functions



commit 3318a3f661da93d0a49bd18ea5344f0be86e4706
Author: JiÅ?í Techet <techet gmail com>
Date:   Sun May 16 00:55:11 2010 +0200

    Call g_object_ref() on data passed to idle functions
    
    Signed-off-by: JiÅ?í Techet <techet gmail com>

 champlain/champlain-base-marker.c     |   12 +++++++++++-
 champlain/champlain-file-cache.c      |    5 ++++-
 champlain/champlain-layer.c           |   25 ++++++++++++++-----------
 champlain/champlain-marker.c          |    8 +++++++-
 champlain/champlain-selection-layer.c |   15 +++++++++++++++
 champlain/champlain-view.c            |   19 +++++++++++++++++--
 6 files changed, 68 insertions(+), 16 deletions(-)
---
diff --git a/champlain/champlain-base-marker.c b/champlain/champlain-base-marker.c
index 6681932..9abe6d2 100644
--- a/champlain/champlain-base-marker.c
+++ b/champlain/champlain-base-marker.c
@@ -136,6 +136,12 @@ champlain_base_marker_set_property (GObject *object,
 }
 
 static void
+champlain_base_marker_dispose (GObject *object)
+{
+  G_OBJECT_CLASS (champlain_base_marker_parent_class)->dispose (object);
+}
+
+static void
 champlain_base_marker_finalize (GObject *object)
 {
   G_OBJECT_CLASS (champlain_base_marker_parent_class)->finalize (object);
@@ -148,6 +154,7 @@ champlain_base_marker_class_init (ChamplainBaseMarkerClass *marker_class)
 
   GObjectClass *object_class = G_OBJECT_CLASS (marker_class);
   object_class->finalize = champlain_base_marker_finalize;
+  object_class->dispose = champlain_base_marker_dispose;
   object_class->get_property = champlain_base_marker_get_property;
   object_class->set_property = champlain_base_marker_set_property;
 
@@ -396,7 +403,10 @@ static void
 on_animation_completed (G_GNUC_UNUSED ClutterAnimation* animation,
     ChamplainBaseMarker *marker)
 {
-  g_idle_add ((GSourceFunc) on_idle, marker);
+  g_idle_add_full (G_PRIORITY_DEFAULT,
+                   (GSourceFunc)on_idle,
+                   g_object_ref (marker),
+                   (GDestroyNotify)g_object_unref);
 }
 
 /**
diff --git a/champlain/champlain-file-cache.c b/champlain/champlain-file-cache.c
index 88c4720..d76f4b5 100644
--- a/champlain/champlain-file-cache.c
+++ b/champlain/champlain-file-cache.c
@@ -972,7 +972,10 @@ void
 champlain_file_cache_purge_on_idle (ChamplainFileCache *file_cache)
 {
   g_return_if_fail (CHAMPLAIN_IS_FILE_CACHE (file_cache));
-  g_idle_add (purge_on_idle, file_cache);
+  g_idle_add_full (G_PRIORITY_DEFAULT,
+                   (GSourceFunc)purge_on_idle,
+                   g_object_ref (file_cache),
+                   (GDestroyNotify)g_object_unref);
 }
 
 /**
diff --git a/champlain/champlain-layer.c b/champlain/champlain-layer.c
index 5e8b8c5..571bcca 100644
--- a/champlain/champlain-layer.c
+++ b/champlain/champlain-layer.c
@@ -39,20 +39,11 @@
 
 G_DEFINE_TYPE (ChamplainLayer, champlain_layer, CLUTTER_TYPE_GROUP)
 
-#define GET_PRIVATE(o) \
-  (G_TYPE_INSTANCE_GET_PRIVATE ((o), CHAMPLAIN_TYPE_LAYER, ChamplainLayerPrivate))
-
 enum
 {
   PROP_0
 };
 
-typedef struct _ChamplainLayerPrivate ChamplainLayerPrivate;
-
-struct _ChamplainLayerPrivate {
-  gpointer spacer;
-};
-
 static void layer_add_cb (ClutterGroup *layer,
     ClutterActor *marker,
     gpointer data);
@@ -89,12 +80,24 @@ champlain_layer_set_property (GObject *object,
 }
 
 static void
+champlain_layer_dispose (GObject *object)
+{
+  G_OBJECT_CLASS (champlain_layer_parent_class)->dispose (object);
+}
+
+static void
+champlain_layer_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (champlain_layer_parent_class)->finalize (object);
+}
+
+static void
 champlain_layer_class_init (ChamplainLayerClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-  g_type_class_add_private (klass, sizeof (ChamplainLayerPrivate));
-
+  object_class->finalize = champlain_layer_finalize;
+  object_class->dispose = champlain_layer_dispose;
   object_class->get_property = champlain_layer_get_property;
   object_class->set_property = champlain_layer_set_property;
 }
diff --git a/champlain/champlain-marker.c b/champlain/champlain-marker.c
index 6efa649..4854853 100644
--- a/champlain/champlain-marker.c
+++ b/champlain/champlain-marker.c
@@ -783,7 +783,13 @@ champlain_marker_queue_redraw (ChamplainMarker *marker)
   ChamplainMarkerPrivate *priv = marker->priv;
 
   if (!priv->redraw_id)
-    priv->redraw_id = g_idle_add (redraw_on_idle, marker);
+    {
+      priv->redraw_id =
+          g_idle_add_full (G_PRIORITY_DEFAULT,
+                           (GSourceFunc)redraw_on_idle,
+                           g_object_ref (marker),
+                           (GDestroyNotify)g_object_unref);
+    }
 }
 
 static void
diff --git a/champlain/champlain-selection-layer.c b/champlain/champlain-selection-layer.c
index 0531ce9..41e3b93 100644
--- a/champlain/champlain-selection-layer.c
+++ b/champlain/champlain-selection-layer.c
@@ -101,12 +101,26 @@ champlain_selection_layer_set_property (GObject *object,
 }
 
 static void
+champlain_selection_layer_dispose (GObject *object)
+{
+  G_OBJECT_CLASS (champlain_selection_layer_parent_class)->dispose (object);
+}
+
+static void
+champlain_selection_layer_finalize (GObject *object)
+{
+  G_OBJECT_CLASS (champlain_selection_layer_parent_class)->finalize (object);
+}
+
+static void
 champlain_selection_layer_class_init (ChamplainSelectionLayerClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
   g_type_class_add_private (klass, sizeof (ChamplainSelectionLayerPrivate));
 
+  object_class->finalize = champlain_selection_layer_finalize;
+  object_class->dispose = champlain_selection_layer_dispose;
   object_class->get_property = champlain_selection_layer_get_property;
   object_class->set_property = champlain_selection_layer_set_property;
 
@@ -143,6 +157,7 @@ static void
 marker_select (ChamplainSelectionLayer *layer,
     ChamplainBaseMarker *marker)
 {
+
   /* Add selection */
   g_object_ref (marker);
   g_object_set (marker, "highlighted", TRUE, NULL);
diff --git a/champlain/champlain-view.c b/champlain/champlain-view.c
index 4a87e95..cd397e7 100644
--- a/champlain/champlain-view.c
+++ b/champlain/champlain-view.c
@@ -451,7 +451,10 @@ layer_add_marker_cb (G_GNUC_UNUSED ClutterGroup *layer,
   g_signal_connect (marker, "notify::longitude",
       G_CALLBACK (notify_marker_reposition_cb), view);
 
-  g_idle_add (marker_reposition, view);
+  g_idle_add_full (G_PRIORITY_DEFAULT,
+                   (GSourceFunc)marker_reposition,
+                   g_object_ref (view),
+                   (GDestroyNotify)g_object_unref);
 }
 
 static void
@@ -811,6 +814,14 @@ champlain_view_dispose (GObject *object)
   G_OBJECT_CLASS (champlain_view_parent_class)->dispose (object);
 }
 
+static void
+champlain_view_finalize (GObject *object)
+{
+  DEBUG_LOG()
+
+  G_OBJECT_CLASS (champlain_view_parent_class)->finalize (object);
+}
+
 static gboolean
 _update_idle_cb (ChamplainView *view)
 {
@@ -945,6 +956,7 @@ champlain_view_class_init (ChamplainViewClass *champlainViewClass)
 
   GObjectClass *object_class = G_OBJECT_CLASS (champlainViewClass);
   object_class->dispose = champlain_view_dispose;
+  object_class->finalize = champlain_view_finalize;
   object_class->get_property = champlain_view_get_property;
   object_class->set_property = champlain_view_set_property;
 
@@ -2213,7 +2225,10 @@ champlain_view_add_layer (ChamplainView *view,
       CLUTTER_ACTOR (layer));
   clutter_actor_raise_top (CLUTTER_ACTOR (layer));
 
-  g_idle_add (marker_reposition, view);
+  g_idle_add_full (G_PRIORITY_DEFAULT,
+                   (GSourceFunc)marker_reposition,
+                   g_object_ref (view),
+                   (GDestroyNotify)g_object_unref);
 
   g_signal_connect_after (layer, "actor-added",
       G_CALLBACK (layer_add_marker_cb), view);



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