[glib] gio/tests/testapps: Fix source refcounting



commit d68f8012b2d8b9b86b47ed1f091f29d70016cf73
Author: Dan Winship <danw gnome org>
Date:   Tue Jun 22 15:31:55 2010 -0400

    gio/tests/testapps: Fix source refcounting
    
    Either child_watch_source or timeout_source will already have been
    destroyed after we finish the loop, and it's not safe to call
    g_source_destroy() on it a second time unless we're still holding a
    ref on it.

 gio/tests/testapps.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/gio/tests/testapps.c b/gio/tests/testapps.c
index 854d7fa..1def170 100644
--- a/gio/tests/testapps.c
+++ b/gio/tests/testapps.c
@@ -142,17 +142,17 @@ await_child_termination_run (AwaitChildTerminationData *data)
   child_watch_source = g_child_watch_source_new (data->pid);
   g_source_set_callback (child_watch_source, (GSourceFunc) on_child_termination_exited, data, NULL);
   g_source_attach (child_watch_source, data->context);
-  g_source_unref (child_watch_source);
 
   timeout_source = g_timeout_source_new_seconds (5);
   g_source_set_callback (timeout_source, on_child_termination_timeout, data, NULL);
   g_source_attach (timeout_source, data->context);
-  g_source_unref (timeout_source);
 
   g_main_loop_run (data->loop);
 
   g_source_destroy (child_watch_source);
+  g_source_unref (child_watch_source);
   g_source_destroy (timeout_source);
+  g_source_unref (timeout_source);
 
   g_main_loop_unref (data->loop);
 



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