[evolution-patches] Use a static POA in ebook



Hi,

Whilst playing with libebook I noticed that the Bonobo POAs are being
newly created for every EBookListener and EBookViewListener created.
Originally I thought that Bonobo should be freeing these as they were
leaking, but it turns out that this is a libebook bug: POAs should be
long-lived.

This patch makes the POAs static in the _new methods, so they are only
created once.  Michael Meeks says this will probably improve performance
too, as multiple POAs is a bad thing.

If this gets commit approval I'll be good and make a changelog entry
too, honest.

Ross
-- 
Ross Burton                                 mail: ross burtonini com
                                          jabber: ross burtonini com
                                     www: http://www.burtonini.com./
 PGP Fingerprint: 1A21 F5B0 D8D0 CFE3 81D4 E25A 2D09 E447 D0B4 33DF

Index: e-book-listener.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-book-listener.c,v
retrieving revision 1.14
diff -u -r1.14 e-book-listener.c
--- e-book-listener.c	4 Feb 2005 06:30:33 -0000	1.14
+++ e-book-listener.c	19 Apr 2005 14:40:31 -0000
@@ -403,9 +403,13 @@
 e_book_listener_new ()
 {
 	EBookListener *listener;
+	static PortableServer_POA poa = NULL;
+
+	if (poa == NULL)
+		poa = bonobo_poa_get_threaded (ORBIT_THREAD_HINT_ON_CONTEXT, _ebook_context, NULL);
 
 	listener = g_object_new (E_TYPE_BOOK_LISTENER,
-				 "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_ON_CONTEXT, _ebook_context, NULL),
+				 "poa", poa,
 				 NULL);
 
 	return listener;
Index: e-book-view-listener.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-book-view-listener.c,v
retrieving revision 1.8
diff -u -r1.8 e-book-view-listener.c
--- e-book-view-listener.c	22 Sep 2004 22:20:33 -0000	1.8
+++ e-book-view-listener.c	19 Apr 2005 14:40:31 -0000
@@ -285,9 +285,13 @@
 e_book_view_listener_new ()
 {
 	EBookViewListener *listener;
+	static PortableServer_POA poa = NULL;
 
+	if (poa == NULL)
+		poa = bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_OBJECT, NULL);
+	
 	listener = g_object_new (E_TYPE_BOOK_VIEW_LISTENER,
-				 "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_OBJECT, NULL),
+				 "poa", poa,
 				 NULL);
 
 	listener->priv->queue = g_async_queue_new();

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]