mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 05:56:14 +01:00
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.
This commit is contained in:
parent
d18a9caf03
commit
a151c97106
@ -315,6 +315,16 @@ test_invoke (void)
|
|||||||
g_assert_cmpint (count, ==, 3);
|
g_assert_cmpint (count, ==, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
quit_loop (gpointer data)
|
||||||
|
{
|
||||||
|
GMainLoop *loop = data;
|
||||||
|
|
||||||
|
g_main_loop_quit (loop);
|
||||||
|
|
||||||
|
return G_SOURCE_REMOVE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
run_inner_loop (gpointer user_data)
|
run_inner_loop (gpointer user_data)
|
||||||
{
|
{
|
||||||
@ -326,13 +336,13 @@ run_inner_loop (gpointer user_data)
|
|||||||
|
|
||||||
inner = g_main_loop_new (ctx, FALSE);
|
inner = g_main_loop_new (ctx, FALSE);
|
||||||
timeout = g_timeout_source_new (100);
|
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_source_attach (timeout, ctx);
|
||||||
|
|
||||||
g_main_loop_run (inner);
|
g_main_loop_run (inner);
|
||||||
g_main_loop_unref (inner);
|
g_main_loop_unref (inner);
|
||||||
|
|
||||||
return TRUE;
|
return G_SOURCE_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -371,7 +381,7 @@ test_child_sources (void)
|
|||||||
g_assert_cmpint (g_source_get_priority (child_c), ==, G_PRIORITY_DEFAULT);
|
g_assert_cmpint (g_source_get_priority (child_c), ==, G_PRIORITY_DEFAULT);
|
||||||
|
|
||||||
end = g_timeout_source_new (1050);
|
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_attach (end, ctx);
|
||||||
g_source_unref (end);
|
g_source_unref (end);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user