Port various timeout/idle callbacks to the once API

So we excercise it in our test coverage.
This commit is contained in:
Emmanuele Bassi 2022-05-24 17:10:32 +01:00 committed by Philip Withnall
parent 12571a0821
commit 50c316ef36
3 changed files with 8 additions and 12 deletions

View File

@ -85,13 +85,12 @@ map_or_die (const gchar *filename,
return map;
}
static gboolean
static void
signal_parent (gpointer data)
{
#ifndef G_OS_WIN32
kill (parent_pid, SIGUSR1);
#endif
return G_SOURCE_REMOVE;
}
static void
@ -113,7 +112,7 @@ child_main (void)
#endif
loop = g_main_loop_new (NULL, FALSE);
g_idle_add (check_stop, loop);
g_idle_add (signal_parent, NULL);
g_idle_add_once (signal_parent, NULL);
g_main_loop_run (loop);
g_test_message ("test_child_private: received parent signal");

View File

@ -5,12 +5,10 @@
static GMainLoop *loop;
static gboolean
static void
stop_waiting (gpointer data)
{
g_main_loop_quit (loop);
return G_SOURCE_REMOVE;
}
static gboolean
@ -44,7 +42,7 @@ test_seconds (void)
g_test_bug ("https://bugzilla.gnome.org/show_bug.cgi?id=642052");
loop = g_main_loop_new (NULL, FALSE);
g_timeout_add (2100, stop_waiting, NULL);
g_timeout_add_once (2100, stop_waiting, NULL);
id = g_timeout_add_seconds (21475, unreachable_callback, NULL);
g_main_loop_run (loop);
@ -81,7 +79,7 @@ test_weeks_overflow (void)
g_test_bug ("https://gitlab.gnome.org/GNOME/glib/issues/1600");
loop = g_main_loop_new (NULL, FALSE);
g_timeout_add (2100, stop_waiting, NULL);
g_timeout_add_once (2100, stop_waiting, NULL);
interval_seconds = 1 + G_MAXUINT / 1000;
id = g_timeout_add_seconds (interval_seconds, unreachable_callback, NULL);

View File

@ -767,11 +767,10 @@ test_os_info (void)
g_free (contents);
}
static gboolean
static void
source_test (gpointer data)
{
g_assert_not_reached ();
return G_SOURCE_REMOVE;
}
static void
@ -779,13 +778,13 @@ test_clear_source (void)
{
guint id;
id = g_idle_add (source_test, NULL);
id = g_idle_add_once (source_test, NULL);
g_assert_cmpuint (id, >, 0);
g_clear_handle_id (&id, g_source_remove);
g_assert_cmpuint (id, ==, 0);
id = g_timeout_add (100, source_test, NULL);
id = g_timeout_add_once (100, source_test, NULL);
g_assert_cmpuint (id, >, 0);
g_clear_handle_id (&id, g_source_remove);