aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy-gtk/empathy-avatar-chooser.c2
-rw-r--r--libempathy-gtk/empathy-contact-list-view.c2
-rw-r--r--libempathy-gtk/empathy-contact-widget.c2
-rw-r--r--libempathy/empathy-contact-factory.c36
-rw-r--r--libempathy/empathy-contact-factory.h2
-rw-r--r--libempathy/empathy-dispatcher.c8
-rw-r--r--libempathy/empathy-tp-chat.c2
-rw-r--r--libempathy/empathy-tp-file.c2
-rw-r--r--libempathy/empathy-tp-group.c2
-rw-r--r--libempathy/empathy-tp-tube.c2
-rw-r--r--megaphone/src/megaphone-applet.c2
-rw-r--r--src/empathy-event-manager.c2
-rw-r--r--src/empathy-main-window.c2
-rw-r--r--tests/contact-run-until-ready.c2
14 files changed, 41 insertions, 27 deletions
diff --git a/libempathy-gtk/empathy-avatar-chooser.c b/libempathy-gtk/empathy-avatar-chooser.c
index 86df44953..5da81b936 100644
--- a/libempathy-gtk/empathy-avatar-chooser.c
+++ b/libempathy-gtk/empathy-avatar-chooser.c
@@ -213,7 +213,7 @@ empathy_avatar_chooser_init (EmpathyAvatarChooser *chooser)
G_CALLBACK (avatar_chooser_clicked_cb),
chooser);
- priv->contact_factory = empathy_contact_factory_new ();
+ priv->contact_factory = empathy_contact_factory_dup_singleton ();
empathy_avatar_chooser_set (chooser, NULL);
}
diff --git a/libempathy-gtk/empathy-contact-list-view.c b/libempathy-gtk/empathy-contact-list-view.c
index 839a0df36..f9fbce92f 100644
--- a/libempathy-gtk/empathy-contact-list-view.c
+++ b/libempathy-gtk/empathy-contact-list-view.c
@@ -213,7 +213,7 @@ contact_list_view_drag_data_received (GtkWidget *widget,
id);
strv = g_strsplit (id, "/", 2);
- factory = empathy_contact_factory_new ();
+ factory = empathy_contact_factory_dup_singleton ();
account = mc_account_lookup (strv[0]);
if (account) {
contact = empathy_contact_factory_get_from_id (factory,
diff --git a/libempathy-gtk/empathy-contact-widget.c b/libempathy-gtk/empathy-contact-widget.c
index 4100a6872..c8a21e858 100644
--- a/libempathy-gtk/empathy-contact-widget.c
+++ b/libempathy-gtk/empathy-contact-widget.c
@@ -162,7 +162,7 @@ empathy_contact_widget_new (EmpathyContact *contact,
information = g_slice_new0 (EmpathyContactWidget);
information->flags = flags;
- information->factory = empathy_contact_factory_new ();
+ information->factory = empathy_contact_factory_dup_singleton ();
filename = empathy_file_lookup ("empathy-contact-widget.glade",
"libempathy-gtk");
diff --git a/libempathy/empathy-contact-factory.c b/libempathy/empathy-contact-factory.c
index e35bc350d..f7f701bea 100644
--- a/libempathy/empathy-contact-factory.c
+++ b/libempathy/empathy-contact-factory.c
@@ -31,6 +31,8 @@ typedef struct {
G_DEFINE_TYPE (EmpathyContactFactory, empathy_contact_factory, G_TYPE_OBJECT);
+static EmpathyContactFactory * factory_singleton = NULL;
+
EmpathyTpContactFactory *
empathy_contact_factory_get_tp_factory (EmpathyContactFactory *factory,
McAccount *account)
@@ -133,12 +135,33 @@ contact_factory_finalize (GObject *object)
G_OBJECT_CLASS (empathy_contact_factory_parent_class)->finalize (object);
}
+static GObject *
+contact_factory_constructor (GType type,
+ guint n_props,
+ GObjectConstructParam *props)
+{
+ GObject *retval;
+
+ if (factory_singleton) {
+ retval = g_object_ref (factory_singleton);
+ } else {
+ retval = G_OBJECT_CLASS (empathy_contact_factory_parent_class)->constructor
+ (type, n_props, props);
+ g_object_add_weak_pointer (retval, (gpointer *) &retval);
+
+ factory_singleton = EMPATHY_CONTACT_FACTORY (retval);
+ }
+
+ return retval;
+}
+
static void
empathy_contact_factory_class_init (EmpathyContactFactoryClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = contact_factory_finalize;
+ object_class->constructor = contact_factory_constructor;
g_type_class_add_private (object_class, sizeof (EmpathyContactFactoryPriv));
}
@@ -157,17 +180,8 @@ empathy_contact_factory_init (EmpathyContactFactory *factory)
}
EmpathyContactFactory *
-empathy_contact_factory_new (void)
+empathy_contact_factory_dup_singleton (void)
{
- static EmpathyContactFactory *factory = NULL;
-
- if (!factory) {
- factory = g_object_new (EMPATHY_TYPE_CONTACT_FACTORY, NULL);
- g_object_add_weak_pointer (G_OBJECT (factory), (gpointer) &factory);
- } else {
- g_object_ref (factory);
- }
-
- return factory;
+ return g_object_new (EMPATHY_TYPE_CONTACT_FACTORY, NULL);
}
diff --git a/libempathy/empathy-contact-factory.h b/libempathy/empathy-contact-factory.h
index 24fec0e03..16df02bcd 100644
--- a/libempathy/empathy-contact-factory.h
+++ b/libempathy/empathy-contact-factory.h
@@ -51,7 +51,7 @@ struct _EmpathyContactFactoryClass {
};
GType empathy_contact_factory_get_type (void) G_GNUC_CONST;
-EmpathyContactFactory *empathy_contact_factory_new (void);
+EmpathyContactFactory *empathy_contact_factory_dup_singleton (void);
EmpathyTpContactFactory *empathy_contact_factory_get_tp_factory (EmpathyContactFactory *factory,
McAccount *account);
EmpathyContact * empathy_contact_factory_get_user (EmpathyContactFactory *factory,
diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c
index 29345e0a3..aaac433c9 100644
--- a/libempathy/empathy-dispatcher.c
+++ b/libempathy/empathy-dispatcher.c
@@ -235,7 +235,7 @@ dispatcher_tubes_new_tube_cb (TpChannel *channel,
tube = g_slice_new (DispatcherTube);
tube->ref_count = 1;
tube->handled = FALSE;
- tube->factory = empathy_contact_factory_new ();
+ tube->factory = empathy_contact_factory_dup_singleton ();
tube->bus_name = empathy_tube_handler_build_bus_name (type, service);
tube->object_path = empathy_tube_handler_build_object_path (type, service);
tube->public.activatable = FALSE;
@@ -850,7 +850,7 @@ empathy_dispatcher_call_with_contact (EmpathyContact *contact)
group = empathy_tp_group_new (channel);
empathy_run_until_ready (group);
- factory = empathy_contact_factory_new ();
+ factory = empathy_contact_factory_dup_singleton ();
self_contact = empathy_contact_factory_get_user (factory, account);
empathy_contact_run_until_ready (self_contact,
EMPATHY_CONTACT_READY_HANDLE,
@@ -873,7 +873,7 @@ empathy_dispatcher_call_with_contact_id (McAccount *account, const gchar *contac
EmpathyContactFactory *factory;
EmpathyContact *contact;
- factory = empathy_contact_factory_new ();
+ factory = empathy_contact_factory_dup_singleton ();
contact = empathy_contact_factory_get_from_id (factory, account, contact_id);
empathy_contact_run_until_ready (contact, EMPATHY_CONTACT_READY_HANDLE, NULL);
@@ -922,7 +922,7 @@ empathy_dispatcher_chat_with_contact_id (McAccount *account,
EmpathyContactFactory *factory;
EmpathyContact *contact;
- factory = empathy_contact_factory_new ();
+ factory = empathy_contact_factory_dup_singleton ();
contact = empathy_contact_factory_get_from_id (factory, account, contact_id);
empathy_contact_run_until_ready (contact, EMPATHY_CONTACT_READY_HANDLE, NULL);
diff --git a/libempathy/empathy-tp-chat.c b/libempathy/empathy-tp-chat.c
index 8517c1c0d..690fa6d3f 100644
--- a/libempathy/empathy-tp-chat.c
+++ b/libempathy/empathy-tp-chat.c
@@ -950,7 +950,7 @@ tp_chat_constructor (GType type,
priv = GET_PRIV (chat);
priv->account = empathy_channel_get_account (priv->channel);
- priv->factory = empathy_contact_factory_new ();
+ priv->factory = empathy_contact_factory_dup_singleton ();
priv->user = empathy_contact_factory_get_user (priv->factory, priv->account);
g_signal_connect (priv->channel, "invalidated",
diff --git a/libempathy/empathy-tp-file.c b/libempathy/empathy-tp-file.c
index c21d780f9..ada0a4354 100644
--- a/libempathy/empathy-tp-file.c
+++ b/libempathy/empathy-tp-file.c
@@ -507,7 +507,7 @@ tp_file_constructor (GType type,
tp_file = EMPATHY_TP_FILE (file_obj);
- tp_file->priv->factory = empathy_contact_factory_new ();
+ tp_file->priv->factory = empathy_contact_factory_dup_singleton ();
tp_file->priv->mc = empathy_mission_control_new ();
g_signal_connect (tp_file->priv->channel, "invalidated",
diff --git a/libempathy/empathy-tp-group.c b/libempathy/empathy-tp-group.c
index c9220382a..c3471c157 100644
--- a/libempathy/empathy-tp-group.c
+++ b/libempathy/empathy-tp-group.c
@@ -570,7 +570,7 @@ tp_group_constructed (GObject *group)
EmpathyTpGroupPriv *priv = GET_PRIV (group);
gboolean channel_ready;
- priv->factory = empathy_contact_factory_new ();
+ priv->factory = empathy_contact_factory_dup_singleton ();
priv->account = empathy_channel_get_account (priv->channel);
g_signal_connect (priv->channel, "invalidated",
diff --git a/libempathy/empathy-tp-tube.c b/libempathy/empathy-tp-tube.c
index 5f421ac78..9d4c66038 100644
--- a/libempathy/empathy-tp-tube.c
+++ b/libempathy/empathy-tp-tube.c
@@ -351,7 +351,7 @@ empathy_tp_tube_init (EmpathyTpTube *tube)
tube->priv = priv;
- priv->factory = empathy_contact_factory_new ();
+ priv->factory = empathy_contact_factory_dup_singleton ();
}
EmpathyTpTube *
diff --git a/megaphone/src/megaphone-applet.c b/megaphone/src/megaphone-applet.c
index 4be4443b8..1d63a2cbb 100644
--- a/megaphone/src/megaphone-applet.c
+++ b/megaphone/src/megaphone-applet.c
@@ -112,7 +112,7 @@ megaphone_applet_init (MegaphoneApplet *applet)
MEGAPHONE_TYPE_APPLET, MegaphoneAppletPriv);
applet->priv = priv;
- priv->factory = empathy_contact_factory_new ();
+ priv->factory = empathy_contact_factory_dup_singleton ();
priv->gconf = gconf_client_get_default ();
/* Image holds the contact avatar */
diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c
index 4b5cfc505..f192b9731 100644
--- a/src/empathy-event-manager.c
+++ b/src/empathy-event-manager.c
@@ -223,7 +223,7 @@ event_manager_filter_channel_cb (EmpathyDispatcher *dispatcher,
McAccount *account;
EmpathyContactFactory *factory;
- factory = empathy_contact_factory_new ();
+ factory = empathy_contact_factory_dup_singleton ();
handle = tp_channel_get_handle (channel, NULL);
account = empathy_channel_get_account (channel);
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index f034638e3..07c236f96 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -1009,7 +1009,7 @@ main_window_edit_personal_information_cb (GtkWidget *widget,
McAccount *account;
account = accounts->data;
- factory = empathy_contact_factory_new ();
+ factory = empathy_contact_factory_dup_singleton ();
contact = empathy_contact_factory_get_user (factory, account);
empathy_contact_run_until_ready (contact,
EMPATHY_CONTACT_READY_HANDLE |
diff --git a/tests/contact-run-until-ready.c b/tests/contact-run-until-ready.c
index 1d263dd05..13fad63a7 100644
--- a/tests/contact-run-until-ready.c
+++ b/tests/contact-run-until-ready.c
@@ -13,7 +13,7 @@ callback (gpointer data)
EmpathyContact *contact;
EmpathyContactReady ready_flags;
- factory = empathy_contact_factory_new ();
+ factory = empathy_contact_factory_dup_singleton ();
account = mc_account_lookup ("jabber0");
contact = empathy_contact_factory_get_from_handle (factory, account, 2);