[telepathy-glib/master] Prevent using the object after a potential dispose
Sjoerd Simons
sjoerd.simons at collabora.co.uk
Sun Aug 23 06:44:39 PDT 2009
Signals and callbacks can cause the object to be unreffed in the callback code,
ensure we don't access the objects fields after it has potentially been
disposed.
Reviewed-by: Will Thompson <will.thompson at collabora.co.uk>
---
telepathy-glib/connection-manager.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/telepathy-glib/connection-manager.c b/telepathy-glib/connection-manager.c
index f91da73..641ffc7 100644
--- a/telepathy-glib/connection-manager.c
+++ b/telepathy-glib/connection-manager.c
@@ -1103,6 +1103,8 @@ tp_connection_manager_idle_read_manager_file (gpointer data)
{
TpConnectionManager *self = TP_CONNECTION_MANAGER (data);
+ self->priv->manager_file_read_idle_id = 0;
+
if (self->priv->protocols == NULL)
{
if (self->priv->manager_file != NULL &&
@@ -1132,11 +1134,15 @@ tp_connection_manager_idle_read_manager_file (gpointer data)
DEBUG ("Got info from file");
/* previously it must have been NONE */
self->info_source = TP_CM_INFO_SOURCE_FILE;
+
+ g_object_ref (self);
g_object_notify ((GObject *) self, "info-source");
g_signal_emit (self, signals[SIGNAL_GOT_INFO], 0,
self->info_source);
tp_connection_manager_ready_or_failed (self, NULL);
+ g_object_unref (self);
+
goto out;
}
}
@@ -1155,8 +1161,6 @@ tp_connection_manager_idle_read_manager_file (gpointer data)
}
out:
- self->priv->manager_file_read_idle_id = 0;
-
return FALSE;
}
--
1.5.6.5
More information about the telepathy-commits
mailing list