[liboobs] Remove idle tasks when destroying objects



commit f01e9b76ed479d3829eacc3a2f74111e6347699a
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Fri Dec 17 19:44:02 2010 +0100

    Remove idle tasks when destroying objects
    
    On updates, individual objects (like OobsGroups) might be destroyed
    while an update signal waiting to be sent, thus calling the signal
    on invalid objects. Also remove previous tasks before adding a new one,
    because we were adding several tasks before processing them.

 oobs/oobs-object.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/oobs/oobs-object.c b/oobs/oobs-object.c
index 1b6d03c..72e35f5 100644
--- a/oobs/oobs-object.c
+++ b/oobs/oobs-object.c
@@ -195,6 +195,9 @@ oobs_object_finalize (GObject *object)
   connection = _oobs_session_get_connection_bus (priv->session);
   dbus_connection_remove_filter (connection, changed_signal_filter, object);
 
+  /* changed_signal_filter() might have added an idle task on the object */
+  g_idle_remove_by_data (object);
+
   g_object_unref (priv->session);
   g_free (priv->remote_object);
   g_free (priv->path);
@@ -245,7 +248,12 @@ changed_signal_filter (DBusConnection *connection,
 
   if (dbus_message_is_signal (message, priv->method, "changed") &&
       dbus_message_has_path (message, priv->path))
-    g_idle_add (object_changed_idle, object);
+    {
+        /* Avoid adding several updates which wouldn't be removed
+         * correctly on finalize() */
+	g_idle_remove_by_data (object);
+	g_idle_add (object_changed_idle, object);
+    }
 
   /* we want the rest of the objects of
    * the same type to get the signal too



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