diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2014-05-26 13:57:05 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2014-05-26 14:53:30 +0200 |
commit | 5139aa6c10219b9fd386caed9d51de3ba6ef38cc (patch) | |
tree | 155bf3eaee8f3aa27697945e8386d29b50952dbe | |
parent | 87d153bd1d7c2fef46f7d8339d41f9cedaf1070c (diff) |
tests/ibus-engine-switch: Don't try to remove non-existing GSource
ibus-engine-switch schedules an idle doing an engine switch, and
also schedules a timeout after 1 microsecond which exits the main
loop. Both of these callbacks will return FALSE, which detaches
the associated GSource from the mainloop and destroys it.
As the only way to exit the mainloop is when the timeout callback runs,
we should not try to run g_source_remove(timeout_id) as it will already
be gone, and this causes a warning.
This commit reorders a bit to make the ordering between the idle and
timeout more obvious, and it gets rid of the calls to g_source_remove()
as they are needed.
-rw-r--r-- | src/tests/ibus-engine-switch.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/tests/ibus-engine-switch.c b/src/tests/ibus-engine-switch.c index 4c99b79c..e9f07750 100644 --- a/src/tests/ibus-engine-switch.c +++ b/src/tests/ibus-engine-switch.c @@ -54,7 +54,7 @@ global_engine_changed_cb (IBusBus *bus, gchar *name, gpointer user_data) } static gboolean -timeout_cb (gpointer user_data) +idle_quit_cb (gpointer user_data) { ibus_quit (); return FALSE; @@ -64,6 +64,7 @@ static gboolean change_global_engine_cb (gpointer user_data) { change_global_engine (); + g_idle_add ((GSourceFunc) idle_quit_cb, NULL); return FALSE; } @@ -71,7 +72,7 @@ static void test_global_engine (void) { GlobalEngineChangedData data; - guint handler_id, timeout_id, idle_id; + guint handler_id; if (!ibus_bus_get_use_global_engine (bus)) return; @@ -82,15 +83,12 @@ test_global_engine (void) "global-engine-changed", G_CALLBACK (global_engine_changed_cb), &data); - timeout_id = g_timeout_add_seconds (1, timeout_cb, &data); - idle_id = g_idle_add ((GSourceFunc) change_global_engine_cb, NULL); + g_idle_add ((GSourceFunc) change_global_engine_cb, NULL); ibus_main (); g_assert_cmpint (data.count, ==, G_N_ELEMENTS (engine_names)); - g_source_remove (idle_id); - g_source_remove (timeout_id); g_signal_handler_disconnect (bus, handler_id); } |