[gnome-user-share] obex: Fix crashes when switching VTs
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-user-share] obex: Fix crashes when switching VTs
- Date: Tue, 12 Nov 2013 13:20:44 +0000 (UTC)
commit 448bc5aed50bf4b7689fd1c9fef57cce7f4dac81
Author: Bastien Nocera <hadess hadess net>
Date: Thu Nov 7 19:09:33 2013 +0100
obex: Fix crashes when switching VTs
We need to unregister the object when disposing it, as otherwise
we'll be trying to register the agent when there's already one
registered (to a non-existant object).
This fixes a crash when fast-user switching, or simply switching
to a VT and coming back.
See https://bugzilla.redhat.com/show_bug.cgi?id=1008653
https://bugzilla.gnome.org/show_bug.cgi?id=711628
src/obexpush.c | 22 ++++++++++++----------
src/obexpush.h | 2 ++
2 files changed, 14 insertions(+), 10 deletions(-)
---
diff --git a/src/obexpush.c b/src/obexpush.c
index ea18a3e..24dccd4 100644
--- a/src/obexpush.c
+++ b/src/obexpush.c
@@ -563,23 +563,24 @@ on_bus_acquired (GDBusConnection *connection,
const gchar *name,
gpointer user_data)
{
- guint id;
+ ObexAgent *self = user_data;
/* parse introspection data */
introspection_data = g_dbus_node_info_new_for_xml (introspection_xml,
NULL);
- id = g_dbus_connection_register_object (connection,
- AGENT_PATH,
- introspection_data->interfaces[0],
- &interface_vtable,
- NULL, /* user_data */
- NULL, /* user_data_free_func */
- NULL); /* GError** */
+ self->connection = connection;
+ self->object_reg_id = g_dbus_connection_register_object (connection,
+ AGENT_PATH,
+ introspection_data->interfaces[0],
+ &interface_vtable,
+ NULL, /* user_data */
+ NULL, /* user_data_free_func */
+ NULL); /* GError** */
g_dbus_node_info_unref (introspection_data);
- g_assert (id > 0);
+ g_assert (self->object_reg_id > 0);
}
static void
@@ -650,6 +651,7 @@ obex_agent_dispose (GObject *obj)
{
ObexAgent *self = OBEX_AGENT (obj);
+ g_dbus_connection_unregister_object (self->connection, self->object_reg_id);
g_bus_unown_name (self->owner_id);
g_clear_object (&client);
@@ -678,7 +680,7 @@ obex_agent_new (void)
on_bus_acquired,
on_name_acquired,
on_name_lost,
- NULL,
+ self,
NULL);
client = bluetooth_client_new ();
diff --git a/src/obexpush.h b/src/obexpush.h
index ddf944e..847655e 100644
--- a/src/obexpush.h
+++ b/src/obexpush.h
@@ -35,6 +35,8 @@ G_BEGIN_DECLS
typedef struct _ObexAgent {
GObject parent;
guint owner_id;
+ guint object_reg_id;
+ GDBusConnection *connection;
} ObexAgent;
typedef struct _ObexAgentClass {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]