[empathy] tp-chat: stop setting the TpAccount during construction
- From: Guillaume Desmottes <gdesmott src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [empathy] tp-chat: stop setting the TpAccount during construction
- Date: Wed, 27 Jun 2012 09:41:45 +0000 (UTC)
commit c3c7502b206eb550c08e8a9271a4087d855038df
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date: Wed Jun 27 11:05:18 2012 +0200
tp-chat: stop setting the TpAccount during construction
It doesn't have to be a property any more, we can just get it from the
TpConnection when we need it.
Should fix a race crash when the TpAccount of the TpConnection is not set yet;
see fdo#51444.
https://bugzilla.gnome.org/show_bug.cgi?id=678807
libempathy/empathy-client-factory.c | 6 +----
libempathy/empathy-tp-chat.c | 46 +++++++----------------------------
libempathy/empathy-tp-chat.h | 1 -
3 files changed, 10 insertions(+), 43 deletions(-)
---
diff --git a/libempathy/empathy-client-factory.c b/libempathy/empathy-client-factory.c
index da647a4..9e915f9 100644
--- a/libempathy/empathy-client-factory.c
+++ b/libempathy/empathy-client-factory.c
@@ -45,12 +45,8 @@ empathy_client_factory_create_channel (TpSimpleClientFactory *factory,
if (!tp_strdiff (chan_type, TP_IFACE_CHANNEL_TYPE_TEXT))
{
- TpAccount *account;
-
- account = tp_connection_get_account (conn);
-
return TP_CHANNEL (empathy_tp_chat_new (
- TP_SIMPLE_CLIENT_FACTORY (factory), account, conn, path,
+ TP_SIMPLE_CLIENT_FACTORY (factory), conn, path,
properties));
}
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index 449d19a..03014ea 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -176,6 +176,7 @@ empathy_tp_chat_add (EmpathyTpChat *self,
const char *object_path;
GPtrArray channels = { (gpointer *) &object_path, 1 };
const char *invitees[2] = { NULL, };
+ TpAccount *account;
invitees[0] = empathy_contact_get_id (contact);
object_path = tp_proxy_get_object_path (self);
@@ -192,7 +193,9 @@ empathy_tp_chat_add (EmpathyTpChat *self,
/* FIXME: InvitationMessage ? */
NULL);
- req = tp_account_channel_request_new (self->priv->account, props,
+ account = empathy_tp_chat_get_account (self);
+
+ req = tp_account_channel_request_new (account, props,
TP_USER_ACTION_TIME_NOT_USER_ACTION);
/* Although this is a MUC, it's anonymous, so CreateChannel is
@@ -659,7 +662,6 @@ tp_chat_dispose (GObject *object)
{
EmpathyTpChat *self = EMPATHY_TP_CHAT (object);
- tp_clear_object (&self->priv->account);
tp_clear_object (&self->priv->remote_contact);
tp_clear_object (&self->priv->user);
@@ -905,9 +907,6 @@ tp_chat_get_property (GObject *object,
switch (param_id)
{
- case PROP_ACCOUNT:
- g_value_set_object (value, self->priv->account);
- break;
case PROP_SELF_CONTACT:
g_value_set_object (value, self->priv->user);
break;
@@ -932,25 +931,6 @@ tp_chat_get_property (GObject *object,
};
}
-static void
-tp_chat_set_property (GObject *object,
- guint param_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- EmpathyTpChat *self = EMPATHY_TP_CHAT (object);
-
- switch (param_id)
- {
- case PROP_ACCOUNT:
- self->priv->account = g_value_dup_object (value);
- break;
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
- break;
- };
-}
-
enum {
FEAT_READY,
N_FEAT
@@ -986,18 +966,9 @@ empathy_tp_chat_class_init (EmpathyTpChatClass *klass)
object_class->dispose = tp_chat_dispose;
object_class->finalize = tp_chat_finalize;
object_class->get_property = tp_chat_get_property;
- object_class->set_property = tp_chat_set_property;
proxy_class->list_features = tp_chat_list_features;
- g_object_class_install_property (object_class, PROP_ACCOUNT,
- g_param_spec_object ("account", "TpAccount",
- "the account associated with the chat",
- TP_TYPE_ACCOUNT,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS));
-
/**
* EmpathyTpChat:self-contact:
*
@@ -1095,18 +1066,15 @@ empathy_tp_chat_init (EmpathyTpChat *self)
EmpathyTpChat *
empathy_tp_chat_new (TpSimpleClientFactory *factory,
- TpAccount *account,
TpConnection *conn,
const gchar *object_path,
const GHashTable *immutable_properties)
{
- g_return_val_if_fail (TP_IS_ACCOUNT (account), NULL);
g_return_val_if_fail (TP_IS_CONNECTION (conn), NULL);
g_return_val_if_fail (immutable_properties != NULL, NULL);
return g_object_new (EMPATHY_TYPE_TP_CHAT,
"factory", factory,
- "account", account,
"connection", conn,
"dbus-daemon", tp_proxy_get_dbus_daemon (conn),
"bus-name", tp_proxy_get_bus_name (conn),
@@ -1143,9 +1111,13 @@ empathy_tp_chat_get_remote_contact (EmpathyTpChat *self)
TpAccount *
empathy_tp_chat_get_account (EmpathyTpChat *self)
{
+ TpConnection *connection;
+
g_return_val_if_fail (EMPATHY_IS_TP_CHAT (self), NULL);
- return self->priv->account;
+ connection = tp_channel_borrow_connection (TP_CHANNEL (self));
+
+ return tp_connection_get_account (connection);
}
void
diff --git a/libempathy/empathy-tp-chat.h b/libempathy/empathy-tp-chat.h
index d3ad334..66fb96d 100644
--- a/libempathy/empathy-tp-chat.h
+++ b/libempathy/empathy-tp-chat.h
@@ -65,7 +65,6 @@ GQuark empathy_tp_chat_get_feature_ready (void) G_GNUC_CONST;
GType empathy_tp_chat_get_type (void) G_GNUC_CONST;
EmpathyTpChat * empathy_tp_chat_new (TpSimpleClientFactory *factory,
- TpAccount *account,
TpConnection *connection,
const gchar *object_path,
const GHashTable *immutable_properties);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]