mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-24 14:36:13 +01:00
gio: Use g_steal_handle_id() with signal unsubscriptions
This makes no functional changes, but does tidy the code up a bit and means `g_steal_handle_id()` gets a bit more testing. Signed-off-by: Philip Withnall <pwithnall@gnome.org>
This commit is contained in:
parent
da5ce72171
commit
6b15af3c4c
@ -544,10 +544,7 @@ g_application_impl_attempt_primary (GApplicationImpl *impl,
|
||||
impl->primary = (rval != DBUS_REQUEST_NAME_REPLY_EXISTS);
|
||||
|
||||
if (!impl->primary && impl->name_lost_signal)
|
||||
{
|
||||
g_dbus_connection_signal_unsubscribe (impl->session_bus, impl->name_lost_signal);
|
||||
impl->name_lost_signal = 0;
|
||||
}
|
||||
g_dbus_connection_signal_unsubscribe (impl->session_bus, g_steal_handle_id (&impl->name_lost_signal));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -592,10 +589,7 @@ g_application_impl_stop_primary (GApplicationImpl *impl)
|
||||
}
|
||||
|
||||
if (impl->name_lost_signal)
|
||||
{
|
||||
g_dbus_connection_signal_unsubscribe (impl->session_bus, impl->name_lost_signal);
|
||||
impl->name_lost_signal = 0;
|
||||
}
|
||||
g_dbus_connection_signal_unsubscribe (impl->session_bus, g_steal_handle_id (&impl->name_lost_signal));
|
||||
|
||||
if (impl->primary && impl->bus_name)
|
||||
{
|
||||
|
@ -1984,10 +1984,7 @@ monitor_on_name_vanished (GDBusConnection *connection,
|
||||
g_print ("The name %s does not have an owner\n", name);
|
||||
|
||||
if (monitor_filter_id != 0)
|
||||
{
|
||||
g_dbus_connection_signal_unsubscribe (connection, monitor_filter_id);
|
||||
monitor_filter_id = 0;
|
||||
}
|
||||
g_dbus_connection_signal_unsubscribe (connection, g_steal_handle_id (&monitor_filter_id));
|
||||
}
|
||||
|
||||
static const GOptionEntry monitor_entries[] =
|
||||
|
@ -423,7 +423,7 @@ g_dbus_action_group_finalize (GObject *object)
|
||||
GDBusActionGroup *group = G_DBUS_ACTION_GROUP (object);
|
||||
|
||||
if (group->subscription_id)
|
||||
g_dbus_connection_signal_unsubscribe (group->connection, group->subscription_id);
|
||||
g_dbus_connection_signal_unsubscribe (group->connection, g_steal_handle_id (&group->subscription_id));
|
||||
|
||||
if (group->actions)
|
||||
g_hash_table_unref (group->actions);
|
||||
|
@ -306,7 +306,7 @@ static void
|
||||
g_dbus_menu_path_deactivate (GDBusMenuPath *path)
|
||||
{
|
||||
if (--path->active == 0)
|
||||
g_dbus_connection_signal_unsubscribe (path->id->connection, path->watch_id);
|
||||
g_dbus_connection_signal_unsubscribe (path->id->connection, g_steal_handle_id (&path->watch_id));
|
||||
}
|
||||
|
||||
static GDBusMenuPath *
|
||||
|
@ -89,9 +89,9 @@ client_unref (Client *client)
|
||||
if (client->disconnected_signal_handler_id > 0)
|
||||
g_signal_handler_disconnect (client->connection, client->disconnected_signal_handler_id);
|
||||
if (client->name_acquired_subscription_id > 0)
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, client->name_acquired_subscription_id);
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, g_steal_handle_id (&client->name_acquired_subscription_id));
|
||||
if (client->name_lost_subscription_id > 0)
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, client->name_lost_subscription_id);
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, g_steal_handle_id (&client->name_lost_subscription_id));
|
||||
g_object_unref (client->connection);
|
||||
}
|
||||
g_main_context_unref (client->main_context);
|
||||
@ -357,11 +357,9 @@ request_name_cb (GObject *source_object,
|
||||
if (connection != NULL)
|
||||
{
|
||||
if (client->name_acquired_subscription_id > 0)
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, client->name_acquired_subscription_id);
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, g_steal_handle_id (&client->name_acquired_subscription_id));
|
||||
if (client->name_lost_subscription_id > 0)
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, client->name_lost_subscription_id);
|
||||
client->name_acquired_subscription_id = 0;
|
||||
client->name_lost_subscription_id = 0;
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, g_steal_handle_id (&client->name_lost_subscription_id));
|
||||
|
||||
g_object_unref (connection);
|
||||
}
|
||||
@ -383,13 +381,11 @@ on_connection_disconnected (GDBusConnection *connection,
|
||||
if (client->disconnected_signal_handler_id > 0)
|
||||
g_signal_handler_disconnect (client->connection, client->disconnected_signal_handler_id);
|
||||
if (client->name_acquired_subscription_id > 0)
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, client->name_acquired_subscription_id);
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, g_steal_handle_id (&client->name_acquired_subscription_id));
|
||||
if (client->name_lost_subscription_id > 0)
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, client->name_lost_subscription_id);
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, g_steal_handle_id (&client->name_lost_subscription_id));
|
||||
g_object_unref (client->connection);
|
||||
client->disconnected_signal_handler_id = 0;
|
||||
client->name_acquired_subscription_id = 0;
|
||||
client->name_lost_subscription_id = 0;
|
||||
client->connection = NULL;
|
||||
|
||||
call_lost_handler (client);
|
||||
@ -969,12 +965,10 @@ g_bus_unown_name (guint owner_id)
|
||||
if (client->disconnected_signal_handler_id > 0)
|
||||
g_signal_handler_disconnect (client->connection, client->disconnected_signal_handler_id);
|
||||
if (client->name_acquired_subscription_id > 0)
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, client->name_acquired_subscription_id);
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, g_steal_handle_id (&client->name_acquired_subscription_id));
|
||||
if (client->name_lost_subscription_id > 0)
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, client->name_lost_subscription_id);
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, g_steal_handle_id (&client->name_lost_subscription_id));
|
||||
client->disconnected_signal_handler_id = 0;
|
||||
client->name_acquired_subscription_id = 0;
|
||||
client->name_lost_subscription_id = 0;
|
||||
if (client->connection != NULL)
|
||||
{
|
||||
g_object_unref (client->connection);
|
||||
|
@ -95,7 +95,7 @@ client_unref (Client *client)
|
||||
if (client->connection != NULL)
|
||||
{
|
||||
if (client->name_owner_changed_subscription_id > 0)
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, client->name_owner_changed_subscription_id);
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, g_steal_handle_id (&client->name_owner_changed_subscription_id));
|
||||
if (client->disconnected_signal_handler_id > 0)
|
||||
g_signal_handler_disconnect (client->connection, client->disconnected_signal_handler_id);
|
||||
g_object_unref (client->connection);
|
||||
@ -306,12 +306,11 @@ on_connection_disconnected (GDBusConnection *connection,
|
||||
return;
|
||||
|
||||
if (client->name_owner_changed_subscription_id > 0)
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, client->name_owner_changed_subscription_id);
|
||||
g_dbus_connection_signal_unsubscribe (client->connection, g_steal_handle_id (&client->name_owner_changed_subscription_id));
|
||||
if (client->disconnected_signal_handler_id > 0)
|
||||
g_signal_handler_disconnect (client->connection, client->disconnected_signal_handler_id);
|
||||
g_object_unref (client->connection);
|
||||
client->disconnected_signal_handler_id = 0;
|
||||
client->name_owner_changed_subscription_id = 0;
|
||||
client->connection = NULL;
|
||||
|
||||
call_vanished_handler (client);
|
||||
|
@ -1218,11 +1218,8 @@ maybe_unsubscribe_signals (GDBusObjectManagerClient *manager)
|
||||
g_return_if_fail (G_IS_DBUS_OBJECT_MANAGER_CLIENT (manager));
|
||||
|
||||
if (manager->priv->signal_subscription_id > 0)
|
||||
{
|
||||
g_dbus_connection_signal_unsubscribe (manager->priv->connection,
|
||||
manager->priv->signal_subscription_id);
|
||||
manager->priv->signal_subscription_id = 0;
|
||||
}
|
||||
g_dbus_connection_signal_unsubscribe (manager->priv->connection,
|
||||
g_steal_handle_id (&manager->priv->signal_subscription_id));
|
||||
|
||||
if (manager->priv->match_rule != NULL)
|
||||
{
|
||||
|
@ -198,15 +198,15 @@ g_dbus_proxy_finalize (GObject *object)
|
||||
|
||||
if (proxy->priv->name_owner_changed_subscription_id > 0)
|
||||
g_dbus_connection_signal_unsubscribe (proxy->priv->connection,
|
||||
proxy->priv->name_owner_changed_subscription_id);
|
||||
g_steal_handle_id (&proxy->priv->name_owner_changed_subscription_id));
|
||||
|
||||
if (proxy->priv->properties_changed_subscription_id > 0)
|
||||
g_dbus_connection_signal_unsubscribe (proxy->priv->connection,
|
||||
proxy->priv->properties_changed_subscription_id);
|
||||
g_steal_handle_id (&proxy->priv->properties_changed_subscription_id));
|
||||
|
||||
if (proxy->priv->signals_subscription_id > 0)
|
||||
g_dbus_connection_signal_unsubscribe (proxy->priv->connection,
|
||||
proxy->priv->signals_subscription_id);
|
||||
g_steal_handle_id (&proxy->priv->signals_subscription_id));
|
||||
|
||||
if (proxy->priv->connection != NULL)
|
||||
g_object_unref (proxy->priv->connection);
|
||||
|
@ -437,8 +437,7 @@ g_fdo_notification_backend_dispose (GObject *object)
|
||||
GDBusConnection *session_bus;
|
||||
|
||||
session_bus = G_NOTIFICATION_BACKEND (backend)->dbus_connection;
|
||||
g_dbus_connection_signal_unsubscribe (session_bus, backend->notify_subscription);
|
||||
backend->notify_subscription = 0;
|
||||
g_dbus_connection_signal_unsubscribe (session_bus, g_steal_handle_id (&backend->notify_subscription));
|
||||
}
|
||||
|
||||
if (backend->notifications)
|
||||
|
@ -177,8 +177,7 @@ response_received (GDBusConnection *connection,
|
||||
guint32 response;
|
||||
|
||||
call_data = g_task_get_task_data (task);
|
||||
g_dbus_connection_signal_unsubscribe (connection, call_data->response_signal_id);
|
||||
call_data->response_signal_id = 0;
|
||||
g_dbus_connection_signal_unsubscribe (connection, g_steal_handle_id (&call_data->response_signal_id));
|
||||
|
||||
g_variant_get (parameters, "(u@a{sv})", &response, NULL);
|
||||
|
||||
@ -232,8 +231,7 @@ open_call_done (GObject *source,
|
||||
{
|
||||
guint signal_id;
|
||||
|
||||
g_dbus_connection_signal_unsubscribe (connection, call_data->response_signal_id);
|
||||
call_data->response_signal_id = 0;
|
||||
g_dbus_connection_signal_unsubscribe (connection, g_steal_handle_id (&call_data->response_signal_id));
|
||||
|
||||
signal_id = g_dbus_connection_signal_subscribe (connection,
|
||||
"org.freedesktop.portal.Desktop",
|
||||
|
@ -371,8 +371,7 @@ test_dbus_properties (void)
|
||||
g_signal_handler_disconnect (controller, notify_id);
|
||||
notify_id = 0;
|
||||
|
||||
g_dbus_connection_signal_unsubscribe (remote_connection, properties_changed_id);
|
||||
properties_changed_id = 0;
|
||||
g_dbus_connection_signal_unsubscribe (remote_connection, g_steal_handle_id (&properties_changed_id));
|
||||
|
||||
g_debug_controller_dbus_stop (controller);
|
||||
while (g_main_context_iteration (NULL, FALSE));
|
||||
|
@ -113,7 +113,7 @@ test_connection_flush (void)
|
||||
g_source_remove (timeout_mainloop_id);
|
||||
}
|
||||
|
||||
g_dbus_connection_signal_unsubscribe (connection, signal_handler_id);
|
||||
g_dbus_connection_signal_unsubscribe (connection, g_steal_handle_id (&signal_handler_id));
|
||||
g_object_unref (connection);
|
||||
|
||||
session_bus_down ();
|
||||
|
@ -793,12 +793,12 @@ test_connection_signals (void)
|
||||
g_assert_cmpint (count_s4, ==, 2);
|
||||
g_assert_cmpint (count_s5, ==, 1);
|
||||
|
||||
g_dbus_connection_signal_unsubscribe (c1, s1);
|
||||
g_dbus_connection_signal_unsubscribe (c1, s2);
|
||||
g_dbus_connection_signal_unsubscribe (c1, s3);
|
||||
g_dbus_connection_signal_unsubscribe (c1, s1b);
|
||||
g_dbus_connection_signal_unsubscribe (c1, s4);
|
||||
g_dbus_connection_signal_unsubscribe (c1, s5);
|
||||
g_dbus_connection_signal_unsubscribe (c1, g_steal_handle_id (&s1));
|
||||
g_dbus_connection_signal_unsubscribe (c1, g_steal_handle_id (&s2));
|
||||
g_dbus_connection_signal_unsubscribe (c1, g_steal_handle_id (&s3));
|
||||
g_dbus_connection_signal_unsubscribe (c1, g_steal_handle_id (&s1b));
|
||||
g_dbus_connection_signal_unsubscribe (c1, g_steal_handle_id (&s4));
|
||||
g_dbus_connection_signal_unsubscribe (c1, g_steal_handle_id (&s5));
|
||||
|
||||
g_object_unref (c1);
|
||||
g_object_unref (c2);
|
||||
@ -852,8 +852,8 @@ test_match_rule (GDBusConnection *connection,
|
||||
g_assert_cmpint (emissions, ==, 1);
|
||||
g_assert_cmpint (matches, ==, should_match ? 1 : 0);
|
||||
|
||||
g_dbus_connection_signal_unsubscribe (connection, subscription_ids[0]);
|
||||
g_dbus_connection_signal_unsubscribe (connection, subscription_ids[1]);
|
||||
g_dbus_connection_signal_unsubscribe (connection, g_steal_handle_id (&subscription_ids[0]));
|
||||
g_dbus_connection_signal_unsubscribe (connection, g_steal_handle_id (&subscription_ids[1]));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1132,7 +1132,7 @@ test_connection_filter (void)
|
||||
timeout_mainloop_id = g_timeout_add (30000, test_connection_filter_on_timeout, NULL);
|
||||
g_main_loop_run (loop);
|
||||
g_source_remove (timeout_mainloop_id);
|
||||
g_dbus_connection_signal_unsubscribe (c, signal_handler_id);
|
||||
g_dbus_connection_signal_unsubscribe (c, g_steal_handle_id (&signal_handler_id));
|
||||
|
||||
/* now test some combinations... */
|
||||
filter_id = g_dbus_connection_add_filter (c,
|
||||
|
@ -895,7 +895,7 @@ fixture_subscribe (Fixture *f,
|
||||
if (subscribe->unsubscribe_immediately)
|
||||
{
|
||||
g_test_message ("\tImmediately unsubscribing");
|
||||
g_dbus_connection_signal_unsubscribe (subscriber, id);
|
||||
g_dbus_connection_signal_unsubscribe (subscriber, g_steal_handle_id (&id));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1285,12 +1285,12 @@ teardown (Fixture *f,
|
||||
g_ptr_array_unref (f->proxies);
|
||||
|
||||
if (f->finished_subscription != 0)
|
||||
g_dbus_connection_signal_unsubscribe (subscriber, f->finished_subscription);
|
||||
g_dbus_connection_signal_unsubscribe (subscriber, g_steal_handle_id (&f->finished_subscription));
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (f->subscriptions); i++)
|
||||
{
|
||||
if (f->subscriptions[i] != 0)
|
||||
g_dbus_connection_signal_unsubscribe (subscriber, f->subscriptions[i]);
|
||||
g_dbus_connection_signal_unsubscribe (subscriber, g_steal_handle_id (&f->subscriptions[i]));
|
||||
}
|
||||
|
||||
g_ptr_array_unref (f->received);
|
||||
|
@ -306,8 +306,7 @@ test_delivery_in_thread_func (gpointer _data)
|
||||
|
||||
g_assert_cmpuint (data.signal_count, ==, 1);
|
||||
|
||||
g_dbus_connection_signal_unsubscribe (c, subscription_id);
|
||||
subscription_id = 0;
|
||||
g_dbus_connection_signal_unsubscribe (c, g_steal_handle_id (&subscription_id));
|
||||
|
||||
while (!data.unsubscribe_complete)
|
||||
g_main_context_iteration (thread_context, TRUE);
|
||||
|
Loading…
Reference in New Issue
Block a user