[glib] GActionGroupExporter: stop using signal IDs
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] GActionGroupExporter: stop using signal IDs
- Date: Mon, 12 Dec 2011 18:37:13 +0000 (UTC)
commit 93f17967e4c6c5194d3c0cc4512169b6bd394bf7
Author: Ryan Lortie <desrt desrt ca>
Date: Mon Dec 12 13:28:09 2011 -0500
GActionGroupExporter: stop using signal IDs
GDBusConnection recently changed to dispatching its GDestroyNotify calls
from an idle instead of on-the-spot. Under the previous regime, we
would destroy-notify the action group export of a GtkApplicationWindow
at the point it was removed from the application (ie: slightly before
being disposed).
With the destroy notify now deferred to an idle, the window has already
been disposed, so the signal handlers have already been disconnected.
Avoid the problem by dropping our use of signal IDs and just do
g_signal_handlers_disconnect_by_func(), which doesn't complain if there
is no connection.
gio/gactiongroupexporter.c | 32 ++++++++++++++++----------------
1 files changed, 16 insertions(+), 16 deletions(-)
---
diff --git a/gio/gactiongroupexporter.c b/gio/gactiongroupexporter.c
index ef8f18a..a399fff 100644
--- a/gio/gactiongroupexporter.c
+++ b/gio/gactiongroupexporter.c
@@ -220,7 +220,6 @@ typedef struct
gchar *object_path;
GHashTable *pending_changes;
GSource *pending_source;
- gulong signal_ids[4];
} GActionGroupExporter;
#define ACTION_ADDED_EVENT (1u<<0)
@@ -558,10 +557,15 @@ static void
g_action_group_exporter_free (gpointer user_data)
{
GActionGroupExporter *exporter = user_data;
- gint i;
- for (i = 0; i < G_N_ELEMENTS (exporter->signal_ids); i++)
- g_signal_handler_disconnect (exporter->action_group, exporter->signal_ids[i]);
+ g_signal_handlers_disconnect_by_func (exporter->action_group,
+ g_action_group_exporter_action_added, exporter);
+ g_signal_handlers_disconnect_by_func (exporter->action_group,
+ g_action_group_exporter_action_enabled_changed, exporter);
+ g_signal_handlers_disconnect_by_func (exporter->action_group,
+ g_action_group_exporter_action_state_changed, exporter);
+ g_signal_handlers_disconnect_by_func (exporter->action_group,
+ g_action_group_exporter_action_removed, exporter);
g_hash_table_unref (exporter->pending_changes);
if (exporter->pending_source)
@@ -651,18 +655,14 @@ g_dbus_connection_export_action_group (GDBusConnection *connection,
exporter->connection = g_object_ref (connection);
exporter->object_path = g_strdup (object_path);
- exporter->signal_ids[0] =
- g_signal_connect (action_group, "action-added",
- G_CALLBACK (g_action_group_exporter_action_added), exporter);
- exporter->signal_ids[1] =
- g_signal_connect (action_group, "action-removed",
- G_CALLBACK (g_action_group_exporter_action_removed), exporter);
- exporter->signal_ids[2] =
- g_signal_connect (action_group, "action-state-changed",
- G_CALLBACK (g_action_group_exporter_action_state_changed), exporter);
- exporter->signal_ids[3] =
- g_signal_connect (action_group, "action-enabled-changed",
- G_CALLBACK (g_action_group_exporter_action_enabled_changed), exporter);
+ g_signal_connect (action_group, "action-added",
+ G_CALLBACK (g_action_group_exporter_action_added), exporter);
+ g_signal_connect (action_group, "action-removed",
+ G_CALLBACK (g_action_group_exporter_action_removed), exporter);
+ g_signal_connect (action_group, "action-state-changed",
+ G_CALLBACK (g_action_group_exporter_action_state_changed), exporter);
+ g_signal_connect (action_group, "action-enabled-changed",
+ G_CALLBACK (g_action_group_exporter_action_enabled_changed), exporter);
return id;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]