[glib] Make the child source test work



commit a151c97106948c6bd21b0e2a71b7c18b1f106ce9
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Apr 23 00:35:37 2012 -0400

    Make the child source test work
    
    On my machine, this test was failing, because the timeout source
    for quitting the inner mainloop was triggering repeatedly. Avoid
    that by explicitly returning G_SOURCE_REMOVE from the callback.

 glib/tests/mainloop.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/glib/tests/mainloop.c b/glib/tests/mainloop.c
index 4986e3d..3f0bcee 100644
--- a/glib/tests/mainloop.c
+++ b/glib/tests/mainloop.c
@@ -316,6 +316,16 @@ test_invoke (void)
 }
 
 static gboolean
+quit_loop (gpointer data)
+{
+  GMainLoop *loop = data;
+
+  g_main_loop_quit (loop);
+
+  return G_SOURCE_REMOVE;
+}
+
+static gboolean
 run_inner_loop (gpointer user_data)
 {
   GMainContext *ctx = user_data;
@@ -326,13 +336,13 @@ run_inner_loop (gpointer user_data)
 
   inner = g_main_loop_new (ctx, FALSE);
   timeout = g_timeout_source_new (100);
-  g_source_set_callback (timeout, (GSourceFunc)g_main_loop_quit, inner, NULL);
+  g_source_set_callback (timeout, quit_loop, inner, NULL);
   g_source_attach (timeout, ctx);
 
   g_main_loop_run (inner);
   g_main_loop_unref (inner);
 
-  return TRUE;
+  return G_SOURCE_CONTINUE;
 }
 
 static void
@@ -371,7 +381,7 @@ test_child_sources (void)
   g_assert_cmpint (g_source_get_priority (child_c), ==, G_PRIORITY_DEFAULT);
 
   end = g_timeout_source_new (1050);
-  g_source_set_callback (end, (GSourceFunc)g_main_loop_quit, loop, NULL);
+  g_source_set_callback (end, quit_loop, loop, NULL);
   g_source_attach (end, ctx);
   g_source_unref (end);
 



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