Unref process_deferred_messages_source when clearing it
authorMike Gorse <mgorse@suse.com>
Wed, 9 Oct 2013 21:22:17 +0000 (16:22 -0500)
committerMike Gorse <mgorse@suse.com>
Fri, 11 Oct 2013 09:35:05 +0000 (04:35 -0500)
Since g_source_attach adds a ref to a source and we keep the source stored
in a global variable and, therefore, do not unref it after attaching it, we
thus need to unref it when it is being destroyed and we clear the global
variable.

https://bugzilla.gnome.org/show_bug.cgi?id=709625

atspi/atspi-misc.c

index 11c4d0f..86c6c15 100644 (file)
@@ -792,6 +792,7 @@ process_deferred_messages_callback (gpointer data)
   if (process_deferred_messages ())
     return G_SOURCE_CONTINUE;
 
+  g_source_unref (process_deferred_messages_source);
   process_deferred_messages_source = NULL;
   return G_SOURCE_REMOVE;
 }
@@ -1661,6 +1662,7 @@ atspi_set_main_context (GMainContext *cnx)
   if (process_deferred_messages_source != NULL)
   {
     g_source_destroy (process_deferred_messages_source);
+    g_source_unref (process_deferred_messages_source);
     process_deferred_messages_source = g_idle_source_new ();
     g_source_set_callback (process_deferred_messages_source,
                            process_deferred_messages_callback, NULL, NULL);