[evolution-patches] Bonobo Ref Counting Patches



So it turns out that none of our bonobo controls were ever being
finalized.  The attached patches reduce the number of issues.  At the
very least now if you start up and quit with any of the 4 major controls
they all finalize now.  There still appear to be some problems if you
switch between controls.  Now, since none of the controls were ever
being destroyed, I had to change a few places to guard against multiple
destroys.



-JP
-- 
JP Rosevear <jpr ximian com>
Ximian, Inc.
? bonobo-ref.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/my-evolution/ChangeLog,v
retrieving revision 1.280
diff -u -r1.280 ChangeLog
--- ChangeLog	5 May 2003 01:03:56 -0000	1.280
+++ ChangeLog	13 May 2003 15:50:39 -0000
@@ -1,3 +1,33 @@
+2003-05-13  JP Rosevear  <jpr ximian com>
+
+	* e-summary.c (e_summary_get_control): accessor
+	(e_summary_set_control): ditto
+	(retrieve_shell_view_interface): util to get the shell view
+	(e_summary_change_current_view): use it
+	(e_summary_set_message): ditto
+	(e_summary_unset_message): ditto
+
+	* e-summary-mail.h: add proto
+
+	* e-summary-mail.c (e_summary_mail_get_info): use the objref of
+	the listener
+	(e_summary_folder_unregister_storage): clean up a registered
+	storage
+	(e_summary_folder_register_storages): store the listener directly
+	(folder_info_pb_changed): unref the listener once we are notified
+	(lazy_register_storages): release and unref the property bag,
+	event and listener
+	(e_summary_folder_init_folder_store): track the listener
+	(e_summary_folder_clear_folder_store): cleanup the folder store
+
+	* e-summary-factory.c (control_activate_cb): we don't get the
+	shell view here any more
+	(e_summary_factory_new_control): don't pass in the shell, set the
+	control on the summary
+
+	* component-factory.c (owner_unset_cb): clear the folder store on
+	destruction
+
 2003-05-02  Not Zed  <NotZed Ximian com>
 
 	[#41849]
Index: component-factory.c
===================================================================
RCS file: /cvs/gnome/evolution/my-evolution/component-factory.c,v
retrieving revision 1.30
diff -u -r1.30 component-factory.c
--- component-factory.c	5 Mar 2003 02:08:38 -0000	1.30
+++ component-factory.c	13 May 2003 15:50:39 -0000
@@ -113,7 +113,10 @@
 owner_unset_cb (EvolutionShellComponent *shell_component,
 		gpointer user_data)
 {
-	/* noop */
+	g_free (evolution_dir);
+	evolution_dir = NULL;
+
+	e_summary_folder_clear_folder_store ();
 }
 
 static BonoboObject *
Index: e-summary-factory.c
===================================================================
RCS file: /cvs/gnome/evolution/my-evolution/e-summary-factory.c,v
retrieving revision 1.20
diff -u -r1.20 e-summary-factory.c
--- e-summary-factory.c	18 Apr 2003 17:44:28 -0000	1.20
+++ e-summary-factory.c	13 May 2003 15:50:40 -0000
@@ -87,25 +87,6 @@
 	BonoboUIComponent *ui_component;
 	
 	ui_component = bonobo_control_get_ui_component (control);
-	
-	if (summary->shell_view_interface == NULL) {
-		Bonobo_ControlFrame control_frame;
-		CORBA_Environment ev;
-
-		control_frame = bonobo_control_get_control_frame (control, NULL);
-		if (control_frame == NULL)
-			goto out;
-
-		CORBA_exception_init (&ev);
-		summary->shell_view_interface = Bonobo_Unknown_queryInterface (control_frame, "IDL:GNOME/Evolution/ShellView:1.0", &ev);
-
-		if (BONOBO_EX (&ev)) {
-			g_warning ("Error getting ShellView. %s", CORBA_exception_id (&ev));
-			summary->shell_view_interface = CORBA_OBJECT_NIL;
-		}
-		CORBA_exception_free (&ev);
-	}
- out:
 
 	if (activate)
 		control_activate (control, ui_component, summary);
@@ -129,7 +110,7 @@
 	BonoboControl *control;
 	GtkWidget *summary;
 
-	summary = e_summary_new (shell, global_preferences);
+	summary = e_summary_new (global_preferences);
 	if (summary == NULL) {
 		return NULL;
 	}
@@ -144,6 +125,8 @@
 		return NULL;
 	}
 
+	e_summary_set_control (summary, control);
+	
 	g_signal_connect (control, "activate", G_CALLBACK (control_activate_cb), summary);
 	g_signal_connect (control, "destroy", G_CALLBACK (control_destroy_cb), summary);
 
Index: e-summary-mail.c
===================================================================
RCS file: /cvs/gnome/evolution/my-evolution/e-summary-mail.c,v
retrieving revision 1.53
diff -u -r1.53 e-summary-mail.c
--- e-summary-mail.c	27 Mar 2003 21:37:07 -0000	1.53
+++ e-summary-mail.c	13 May 2003 15:50:40 -0000
@@ -54,7 +54,8 @@
 	GNOME_Evolution_Shell shell;
 	GNOME_Evolution_FolderInfo folder_info;
 	GNOME_Evolution_StorageRegistry registry;
-	Bonobo_Listener corba_listener;
+	BonoboListener *registry_listener;
+	BonoboListener *listener;
 	EvolutionStorageListener *storage_listener;
 	
 	GSList *storage_list;
@@ -226,7 +227,7 @@
 
 	CORBA_exception_init (&ev);
 	GNOME_Evolution_FolderInfo_getInfo (folder_store->folder_info, uri ? uri : "",
-					    folder_store->corba_listener, &ev);
+					    BONOBO_OBJREF (folder_store->listener), &ev);
 	if (BONOBO_EX (&ev)) {
 		g_warning ("Error getting info for %s:\n%s", uri,
 			   CORBA_exception_id (&ev));
@@ -425,6 +426,41 @@
 	return TRUE;
 }
 
+static gboolean
+e_summary_folder_unregister_storage (StorageInfo *si, gboolean remove)
+{
+	GNOME_Evolution_StorageListener corba_listener;
+	CORBA_Environment ev;
+	
+	g_free (si->name);
+	bonobo_object_release_unref (si->storage, NULL);
+
+	corba_listener = evolution_storage_listener_corba_objref (si->listener);
+
+	CORBA_exception_init (&ev);
+	GNOME_Evolution_Storage_removeListener (si->storage, corba_listener, &ev);
+	if (BONOBO_EX (&ev)) {
+		g_warning ("Exception removing listener: %s", 
+			   CORBA_exception_id (&ev));
+		CORBA_exception_free (&ev);
+		
+		return FALSE;
+	}
+	CORBA_exception_free (&ev);
+
+	g_signal_handlers_disconnect_matched (si->listener, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, si);
+	g_object_unref (si->listener);
+	
+	/* FIXME Folders */
+
+	if (remove)
+		folder_store->storage_list = g_slist_remove (folder_store->storage_list, si);
+	
+	g_free (si);
+
+	return TRUE;
+}
+
 static void
 e_summary_folder_register_local_storage (void)
 {
@@ -496,7 +532,6 @@
 e_summary_folder_register_storages (GNOME_Evolution_Shell corba_shell)
 {
 	Bonobo_Listener corba_listener;
-	BonoboListener *listener;
 	CORBA_Environment ev;
 
 	CORBA_exception_init (&ev);
@@ -510,9 +545,9 @@
 		return FALSE;
 	}
 
-	listener = bonobo_listener_new (NULL, NULL);
-	g_signal_connect (listener, "event-notify", G_CALLBACK (storage_notify), NULL);
-	corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener));
+	folder_store->registry_listener = bonobo_listener_new (NULL, NULL);
+	g_signal_connect (folder_store->registry_listener, "event-notify", G_CALLBACK (storage_notify), NULL);
+	corba_listener = BONOBO_OBJREF (folder_store->registry_listener);
 
 	/* Storages will be added whenever the listener gets an event. */
 	GNOME_Evolution_StorageRegistry_addListener (folder_store->registry, corba_listener, &ev);
@@ -621,7 +656,8 @@
 			CORBA_Environment *ev,
 			gpointer data)
 {
-	e_summary_folder_register_storages (folder_store->shell); 
+	e_summary_folder_register_storages (folder_store->shell);
+	bonobo_object_unref (listener);
 }
 
 static void
@@ -630,7 +666,6 @@
 	Bonobo_PropertyBag pb;
 	Bonobo_EventSource event;
 	BonoboListener *listener;
-	Bonobo_Listener corba_listener;
 	CORBA_Environment ev;
 	gboolean ready;
 	
@@ -652,6 +687,7 @@
 	if (ready == TRUE) {
 		/* Register storages */
 		e_summary_folder_register_storages (folder_store->shell); 
+		bonobo_object_release_unref (pb, NULL);		
 		return;
 	}
 	
@@ -662,6 +698,7 @@
 		g_warning ("Error getting event source interface: %s",
 			   CORBA_exception_id (&ev));
 		CORBA_exception_free (&ev);
+		bonobo_object_release_unref (pb, NULL);
 		return;
 	}
 
@@ -669,22 +706,22 @@
 	listener = bonobo_listener_new (NULL, NULL);
 	g_signal_connect (listener, "event-notify", G_CALLBACK (folder_info_pb_changed), NULL);
 	
-	corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener));
-	Bonobo_EventSource_addListener (event, corba_listener, &ev);
+	Bonobo_EventSource_addListener (event, BONOBO_OBJREF (listener), &ev);
 	if (BONOBO_EX (&ev)) {
 		g_warning ("Error adding listener: %s\n",
 			   CORBA_exception_id (&ev));
 		CORBA_exception_free (&ev);
 		bonobo_object_unref (BONOBO_OBJECT (listener));
-		return;
 	}
+
+	bonobo_object_release_unref (pb, NULL);
+	bonobo_object_release_unref (event, NULL);
 }
 
 gboolean
 e_summary_folder_init_folder_store (GNOME_Evolution_Shell shell)
 {
 	CORBA_Environment ev;
-	BonoboListener *listener;
 
 	if (folder_store != NULL) {
 		return TRUE;
@@ -704,9 +741,8 @@
 
 	CORBA_exception_free (&ev);
 
-	listener = bonobo_listener_new (NULL, NULL);
-	g_signal_connect (listener, "event-notify", G_CALLBACK (mail_change_notify), NULL);
-	folder_store->corba_listener = bonobo_object_corba_objref (BONOBO_OBJECT (listener));
+	folder_store->listener = bonobo_listener_new (NULL, NULL);
+	g_signal_connect (folder_store->listener, "event-notify", G_CALLBACK (mail_change_notify), NULL);
 	
 	/* Create a hash table for the folders */
 	folder_store->path_to_folder = g_hash_table_new (g_str_hash, g_str_equal);
@@ -714,5 +750,30 @@
 
 	/* Wait for the mailer to tell us we're ready to register */
 	lazy_register_storages ();
+	return TRUE;
+}
+
+
+gboolean
+e_summary_folder_clear_folder_store (void)
+{
+	GSList *l;
+	
+	if (folder_store == NULL) {
+		return TRUE;
+	}
+
+	bonobo_object_release_unref (folder_store->folder_info, NULL);
+	bonobo_object_release_unref (folder_store->registry, NULL);
+	bonobo_object_unref (folder_store->registry_listener);
+	bonobo_object_unref (folder_store->listener);
+
+	for (l = folder_store->storage_list; l != NULL; l = l->next)
+		e_summary_folder_unregister_storage (l->data, FALSE);
+	g_slist_free (folder_store->storage_list);
+	
+	g_free (folder_store);
+	folder_store = NULL;
+	
 	return TRUE;
 }
Index: e-summary-mail.h
===================================================================
RCS file: /cvs/gnome/evolution/my-evolution/e-summary-mail.h,v
retrieving revision 1.9
diff -u -r1.9 e-summary-mail.h
--- e-summary-mail.h	4 Apr 2002 12:10:37 -0000	1.9
+++ e-summary-mail.h	13 May 2003 15:50:40 -0000
@@ -51,4 +51,5 @@
 
 /* Folder stuff */
 gboolean e_summary_folder_init_folder_store (GNOME_Evolution_Shell shell);
+gboolean e_summary_folder_clear_folder_store (void);
 #endif
Index: e-summary.c
===================================================================
RCS file: /cvs/gnome/evolution/my-evolution/e-summary.c,v
retrieving revision 1.60
diff -u -r1.60 e-summary.c
--- e-summary.c	9 Apr 2003 08:02:45 -0000	1.60
+++ e-summary.c	13 May 2003 15:50:40 -0000
@@ -94,7 +94,7 @@
 };
 
 struct _ESummaryPrivate {
-	GNOME_Evolution_ShellView shell_view_interface;
+	BonoboControl *control;
 
 	GtkWidget *html_scroller;
 	GtkWidget *html;
@@ -508,6 +508,8 @@
 
 	priv = summary->priv;
 
+	priv->control = NULL;
+	
 	priv->frozen = TRUE;
 	priv->pending_reload_tag = 0;
 
@@ -554,13 +556,12 @@
 	     e_summary_init, PARENT_TYPE);
 
 GtkWidget *
-e_summary_new (const GNOME_Evolution_Shell shell,
-	       ESummaryPrefs *prefs)
+e_summary_new (ESummaryPrefs *prefs)
 {
 	ESummary *summary;
 
 	summary = gtk_type_new (e_summary_get_type ());
-	summary->shell = shell;
+
 	/* Just get a pointer to the global preferences */
 	summary->preferences = prefs;
 	
@@ -576,6 +577,30 @@
 	return GTK_WIDGET (summary);
 }
 
+BonoboControl *
+e_summary_get_control (ESummary *summary)
+{
+	g_return_val_if_fail (summary != NULL, CORBA_OBJECT_NIL);
+	g_return_val_if_fail (IS_E_SUMMARY (summary), CORBA_OBJECT_NIL);
+
+	return summary->priv->control;
+}
+
+void 
+e_summary_set_control (ESummary *summary, BonoboControl *control)
+{
+	g_return_if_fail (summary != NULL);
+	g_return_if_fail (IS_E_SUMMARY (summary));
+
+	if (summary->priv->control)
+		g_object_remove_weak_pointer (G_OBJECT (summary->priv->control), &summary->priv->control);
+	
+	summary->priv->control = control;
+
+	if (summary->priv->control)
+		g_object_add_weak_pointer (G_OBJECT (summary->priv->control), &summary->priv->control);
+}
+
 static void
 do_summary_print (ESummary *summary,
 		  gboolean preview)
@@ -669,6 +694,31 @@
 	g_hash_table_insert (summary->priv->protocol_hash, g_strdup (protocol), old);
 }
 
+static GNOME_Evolution_ShellView
+retrieve_shell_view_interface (BonoboControl *control)
+{
+	Bonobo_ControlFrame control_frame;
+	GNOME_Evolution_ShellView shell_view_interface;
+	CORBA_Environment ev;
+	
+	control_frame = bonobo_control_get_control_frame (control, NULL);
+	
+	if (control_frame == NULL)
+		return CORBA_OBJECT_NIL;
+	
+	CORBA_exception_init (&ev);
+	shell_view_interface = Bonobo_Unknown_queryInterface (control_frame,
+							      "IDL:GNOME/Evolution/ShellView:1.0",
+							      &ev);
+
+	if (BONOBO_EX (&ev))
+		shell_view_interface = CORBA_OBJECT_NIL;
+	
+	CORBA_exception_free (&ev);
+	
+	return shell_view_interface;
+}
+
 void
 e_summary_change_current_view (ESummary *summary,
 			       const char *uri)
@@ -679,14 +729,15 @@
 	g_return_if_fail (summary != NULL);
 	g_return_if_fail (IS_E_SUMMARY (summary));
 
-	svi = summary->shell_view_interface;
-	if (svi == NULL) {
+	svi = retrieve_shell_view_interface (summary->priv->control);
+	if (svi == CORBA_OBJECT_NIL)
 		return;
-	}
 
 	CORBA_exception_init (&ev);
 	GNOME_Evolution_ShellView_changeCurrentView (svi, uri, &ev);
 	CORBA_exception_free (&ev);
+
+	bonobo_object_release_unref (svi, NULL);
 }
 
 void
@@ -700,14 +751,15 @@
 	g_return_if_fail (summary != NULL);
 	g_return_if_fail (IS_E_SUMMARY (summary));
 
-	svi = summary->shell_view_interface;
-	if (svi == NULL) {
+	svi = retrieve_shell_view_interface (summary->priv->control);
+	if (svi == CORBA_OBJECT_NIL)
 		return;
-	}
 
 	CORBA_exception_init (&ev);
 	GNOME_Evolution_ShellView_setMessage (svi, message ? message : "", busy, &ev);
 	CORBA_exception_free (&ev);
+
+	bonobo_object_release_unref (svi, NULL);
 }
 
 void
@@ -719,14 +771,15 @@
 	g_return_if_fail (summary != NULL);
 	g_return_if_fail (IS_E_SUMMARY (summary));
 
-	svi = summary->shell_view_interface;
-	if (svi == NULL) {
+	svi = retrieve_shell_view_interface (summary->priv->control);
+	if (svi == CORBA_OBJECT_NIL)
 		return;
-	}
 
 	CORBA_exception_init (&ev);
 	GNOME_Evolution_ShellView_unsetMessage (svi, &ev);
 	CORBA_exception_free (&ev);
+
+	bonobo_object_release_unref (svi, NULL);
 }
 
 void
Index: e-summary.h
===================================================================
RCS file: /cvs/gnome/evolution/my-evolution/e-summary.h,v
retrieving revision 1.22
diff -u -r1.22 e-summary.h
--- e-summary.h	2 Dec 2002 03:19:25 -0000	1.22
+++ e-summary.h	13 May 2003 15:50:40 -0000
@@ -25,6 +25,7 @@
 
 #include <gtk/gtkvbox.h>
 #include <bonobo/bonobo-ui-component.h>
+#include <bonobo/bonobo-control.h>
 #include "e-summary-type.h"
 #include "e-summary-mail.h"
 #include "e-summary-calendar.h"
@@ -117,9 +118,6 @@
 
 	ESummaryPrivate *priv;
 
-	GNOME_Evolution_Shell shell;
-	GNOME_Evolution_ShellView shell_view_interface;
-
 	gboolean online;
 
 	char *timezone;
@@ -132,8 +130,11 @@
 
 
 GtkType e_summary_get_type (void);
-GtkWidget *e_summary_new (const GNOME_Evolution_Shell shell,
-			  ESummaryPrefs *prefs);
+GtkWidget *e_summary_new (ESummaryPrefs *prefs);
+
+BonoboControl *e_summary_get_control (ESummary *summary);
+void e_summary_set_control (ESummary *summary, 
+			    BonoboControl *control);
 
 void e_summary_print (BonoboUIComponent *component,
 		      gpointer user_data,
? bonobo-ref.patch
? ref.txt
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/ChangeLog,v
retrieving revision 1.1401
diff -u -r1.1401 ChangeLog
--- ChangeLog	12 May 2003 08:54:39 -0000	1.1401
+++ ChangeLog	13 May 2003 15:50:52 -0000
@@ -1,3 +1,25 @@
+2003-05-13  JP Rosevear  <jpr ximian com>
+
+	* gui/component/addressbook.c (addressbook_view_unref): clear the
+	view
+	(book_open_cb): track the book in the view, don't unref the book
+	(set_prop): set the book
+	(retrieve_shell_view_interface_from_control): get the shell view
+	every time
+	(set_folder_bar_label): release and unref the shell view
+
+	* gui/component/addressbook-storage.h: add proto
+
+	* gui/component/addressbook-storage.c
+	(addressbook_storage_cleanup): unref the storage
+
+	* gui/component/addressbook-component.c (owner_unset_cb): clean up
+	storage
+
+	* backend/ebook/e-book.c (e_book_load_uri): track the listener
+	signal
+	(e_book_dispose): unref the listener and disconnect the signal
+
 2003-05-12  Sean Gao  <sean gao sun com>
 
 	* gui/contact-list-editor/e-contact-list-editor.c
Index: backend/ebook/e-book.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/backend/ebook/e-book.c,v
retrieving revision 1.72
diff -u -r1.72 e-book.c
--- backend/ebook/e-book.c	26 Feb 2003 22:39:27 -0000	1.72
+++ backend/ebook/e-book.c	13 May 2003 15:50:52 -0000
@@ -57,6 +57,7 @@
 
 	gchar *uri;
 
+	gulong listener_signal;
 	gulong died_signal;
 };
 
@@ -773,8 +774,8 @@
 		return;
 	}
 
-	g_signal_connect (book->priv->listener, "responses_queued",
-			  G_CALLBACK (e_book_check_listener_queue), book);
+	book->priv->listener_signal = g_signal_connect (book->priv->listener, "responses_queued",
+							G_CALLBACK (e_book_check_listener_queue), book);
 
 	load_uri_data = g_new (EBookLoadURIData, 1);
 	load_uri_data->open_response = open_response;
@@ -1605,9 +1606,15 @@
 				CORBA_exception_init (&ev);
 			}
 		}
-
+		
 		CORBA_exception_free (&ev);
 
+		if (book->priv->listener) {
+			g_signal_handler_disconnect (book->priv->comp_listener, book->priv->listener_signal);
+			bonobo_object_unref (book->priv->listener);
+			book->priv->listener = NULL;
+		}
+		
 		if (book->priv->comp_listener) {
 			g_signal_handler_disconnect (book->priv->comp_listener, book->priv->died_signal);
 			g_object_unref (book->priv->comp_listener);
Index: gui/component/addressbook-component.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/component/addressbook-component.c,v
retrieving revision 1.86
diff -u -r1.86 addressbook-component.c
--- gui/component/addressbook-component.c	5 Mar 2003 02:05:34 -0000	1.86
+++ gui/component/addressbook-component.c	13 May 2003 15:50:52 -0000
@@ -390,6 +390,8 @@
 
 	if (owner_count == 0)
 		global_shell_client = NULL;
+
+	addressbook_storage_cleanup ();
 }
 
 /* FIXME We should perhaps take the time to figure out if the book is editable. */
Index: gui/component/addressbook-storage.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/component/addressbook-storage.c,v
retrieving revision 1.49
diff -u -r1.49 addressbook-storage.c
--- gui/component/addressbook-storage.c	18 Dec 2002 22:11:24 -0000	1.49
+++ gui/component/addressbook-storage.c	13 May 2003 15:50:53 -0000
@@ -107,6 +107,15 @@
 #endif 
 }
 
+void
+addressbook_storage_cleanup (void)
+{
+	if (storage != NULL) {
+		bonobo_object_unref (storage);
+		storage = NULL;
+	}
+}
+
 #ifdef HAVE_LDAP
 static void
 notify_listener (const Bonobo_Listener listener, 
Index: gui/component/addressbook-storage.h
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/component/addressbook-storage.h,v
retrieving revision 1.15
diff -u -r1.15 addressbook-storage.h
--- gui/component/addressbook-storage.h	21 Nov 2002 01:23:21 -0000	1.15
+++ gui/component/addressbook-storage.h	13 May 2003 15:50:53 -0000
@@ -64,6 +64,7 @@
 
 void addressbook_storage_setup (EvolutionShellComponent *shell_component,
 				const char *evolution_homedir);
+void addressbook_storage_cleanup (void);
 
 EvolutionStorage  *addressbook_get_other_contact_storage (void);
 GList             *addressbook_storage_get_sources (void);
Index: gui/component/addressbook.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/component/addressbook.c,v
retrieving revision 1.208
diff -u -r1.208 addressbook.c
--- gui/component/addressbook.c	18 Apr 2003 17:44:14 -0000	1.208
+++ gui/component/addressbook.c	13 May 2003 15:50:53 -0000
@@ -77,6 +77,7 @@
 	ESearchBar *search;
 	gint        ecml_changed_id;
 	GtkWidget *vbox;
+	EBook *book;
 	EvolutionActivityClient *activity;
 	BonoboControl *control;
 	BonoboPropertyBag *properties;
@@ -422,23 +423,6 @@
 	}
 }
 
-static void
-addressbook_view_ref (AddressbookView *view)
-{
-	g_assert (view->refs > 0);
-	++view->refs;
-}
-
-static void
-addressbook_view_unref (AddressbookView *view)
-{
-	g_assert (view->refs > 0);
-	--view->refs;
-	if (view->refs == 0) {
-		g_free (view);
-	}
-}
-
 static ECategoriesMasterList *
 get_master_list (void)
 {
@@ -452,24 +436,15 @@
 static void
 addressbook_view_clear (AddressbookView *view)
 {
-	EBook *book;
-
-	if (view->uri && view->view) {
-		g_object_get(view->view,
-			     "book", &book,
-			     NULL);
-		g_object_unref (book);
+	if (view->book) {
+		g_object_unref (view->book);
+		view->book = NULL;
 	}
 	
 	if (view->properties) {
 		bonobo_object_unref (BONOBO_OBJECT(view->properties));
 		view->properties = NULL;
 	}
-
-	if (view->view) {
-		gtk_widget_destroy (GTK_WIDGET (view->view));
-		view->view = NULL;
-	}
 		
 	g_free(view->passwd);
 	view->passwd = NULL;
@@ -477,9 +452,6 @@
 	g_free(view->uri);
 	view->uri = NULL;
 
-	if (view->refs == 0)
-		g_free(view);
-
 	if (view->ecml_changed_id != 0) {
 		g_signal_handler_disconnect (get_master_list(),
 					     view->ecml_changed_id);
@@ -488,16 +460,31 @@
 }
 
 static void
+addressbook_view_ref (AddressbookView *view)
+{
+	g_assert (view->refs > 0);
+	++view->refs;
+}
+
+static void
+addressbook_view_unref (AddressbookView *view)
+{
+	g_assert (view->refs > 0);
+	--view->refs;
+	if (view->refs == 0) {
+		addressbook_view_clear (view);
+		g_free (view);
+	}
+}
+
+static void
 book_open_cb (EBook *book, EBookStatus status, gpointer closure)
 {
 	AddressbookView *view = closure;
 
 	if (status == E_BOOK_STATUS_SUCCESS) {
 		view->failed_to_load = FALSE;
-
-		g_object_set(view->view,
-			     "book", book,
-			     NULL);
+		view->book = book;
 	}
 	else {
 		char *label_string;
@@ -562,17 +549,12 @@
 
 		gtk_widget_show_all (warning_dialog);
 	}
-
-	g_object_unref (book);
 }
 
 static void
 destroy_callback(gpointer data, GObject *where_object_was)
 {
 	AddressbookView *view = data;
-	if (view->view && view->view->model && view->view->model->book_view)
-		e_book_view_stop (view->view->model->book_view);
-	addressbook_view_clear (view);
 	addressbook_view_unref (view);
 }
 
@@ -767,20 +749,16 @@
 	AddressbookView *view = user_data;
 
 	char *uri_data;
-	EBook *book;
 	
 	switch (arg_id) {
 
 	case PROPERTY_FOLDER_URI_IDX:
-		g_object_get(view->view,
-			     "book", &book,
-			     NULL);
 		if (view->uri) {
 			/* we've already had a uri set on this view, so unload it */
-			e_book_unload_uri (book);
+			e_book_unload_uri (view->book); 
 			g_free (view->uri);
 		} else {
-			book = e_book_new ();
+			view->book = e_book_new ();
 		}
 
 		view->failed_to_load = FALSE;
@@ -789,7 +767,7 @@
 		
 		uri_data = e_book_expand_uri (view->uri);
 
-		addressbook_load_uri (book, uri_data, book_open_cb, view);
+		addressbook_load_uri (view->book, uri_data, book_open_cb, view);
 
 		g_free(uri_data);
 
@@ -920,12 +898,6 @@
 	GNOME_Evolution_ShellView shell_view_interface;
 	CORBA_Environment ev;
 
-	shell_view_interface = g_object_get_data (G_OBJECT (control),
-						  "shell_view_interface");
-
-	if (shell_view_interface)
-		return shell_view_interface;
-
 	control_frame = bonobo_control_get_control_frame (control, NULL);
 
 	if (control_frame == NULL)
@@ -937,13 +909,6 @@
 							       &ev);
 	CORBA_exception_free (&ev);
 
-	if (shell_view_interface != CORBA_OBJECT_NIL)
-		g_object_set_data (G_OBJECT (control),
-				   "shell_view_interface",
-				   shell_view_interface);
-	else
-		g_warning ("Control frame doesn't have Evolution/ShellView.");
-
 	return shell_view_interface;
 }
 
@@ -1051,6 +1016,8 @@
 			   bonobo_exception_get_text (&ev));
 
 	CORBA_exception_free (&ev);
+
+	bonobo_object_release_unref (shell_view_interface, NULL);
 }
 
 /* Our global singleton config database */
? bonobo-ref.patch
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.1761
diff -u -r1.1761 ChangeLog
--- ChangeLog	8 May 2003 14:02:34 -0000	1.1761
+++ ChangeLog	13 May 2003 15:51:09 -0000
@@ -1,3 +1,35 @@
+2003-05-13  JP Rosevear  <jpr ximian com>
+
+	* gui/e-tasks.c (e_tasks_destroy): guard against multiple destroys
+
+	* cal-client/cal-client.c (cal_client_finalize): unref the
+	bonobo listener
+
+	* gui/gnome-cal.c (gnome_calendar_destroy): guard against multiple
+	destroy calls
+
+	* gui/e-week-view.c (e_week_view_init): connect after destroy
+	(invisible_destroyed): don't unref, its already destroyed
+
+	* gui/e-day-view.c (e_day_view_init): connect after destroy
+	(invisible_destroyed): don't unref, its already destroyed
+
+	* gui/e-calendar-table.c (e_calendar_table_class_init): make sure
+	we set the parent class
+	(e_calendar_table_init): connect after the destroy handler runs
+	(e_calendar_table_destroy): guard against multiple destroys
+	(invisible_destroyed): don't unref the invisible, its already
+	being destroyed
+
+	* gui/calendar-offline-handler.c (backend_cal_set_mode): unref the
+	client, we are done with it now
+	(backend_cal_opened_online): ditto
+	(impl_dispose): unref our main client
+
+	* gui/calendar-commands.c (control_util_set_folder_bar_label):
+	release/unref the shell view once we are done with it
+	(control_util_show_settings): ditto
+
 2003-05-07  JP Rosevear  <jpr ximian com>
 
 	* gui/dialogs/task-page.glade: fix button conversion problem
Index: cal-client/cal-client.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/cal-client/cal-client.c,v
retrieving revision 1.116
diff -u -r1.116 cal-client.c
--- cal-client/cal-client.c	7 May 2003 13:42:01 -0000	1.116
+++ cal-client/cal-client.c	13 May 2003 15:51:10 -0000
@@ -428,6 +428,7 @@
 	/* The server unrefs the query listener, so we just NULL it out here */
 	if (priv->listener) {
 		cal_listener_stop_notification (priv->listener);
+		bonobo_object_unref (priv->listener);
 		priv->listener = NULL;
 	}
 
Index: gui/calendar-commands.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/calendar-commands.c,v
retrieving revision 1.118
diff -u -r1.118 calendar-commands.c
--- gui/calendar-commands.c	22 Apr 2003 18:06:36 -0000	1.118
+++ gui/calendar-commands.c	13 May 2003 15:51:10 -0000
@@ -482,6 +482,8 @@
 		g_message ("control_util_set_folder_bar_label(): Could not set the folder bar label");
 
 	CORBA_exception_free (&ev);
+
+	bonobo_object_release_unref (shell_view, NULL);
 }
 
 void
@@ -507,6 +509,8 @@
 		g_message ("control_util_show_settings(): Could not show settings");
 
 	CORBA_exception_free (&ev);
+
+	bonobo_object_release_unref (shell_view, NULL);
 }
 
 /* Sensitizes the UI Component menu/toolbar calendar commands based on the
Index: gui/calendar-offline-handler.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/calendar-offline-handler.c,v
retrieving revision 1.12
diff -u -r1.12 calendar-offline-handler.c
--- gui/calendar-offline-handler.c	5 Mar 2003 13:03:16 -0000	1.12
+++ gui/calendar-offline-handler.c	13 May 2003 15:51:11 -0000
@@ -39,7 +39,7 @@
 
 struct _CalendarOfflineHandlerPrivate {
 	CalClient *client;
-	
+
 	GNOME_Evolution_OfflineProgressListener listener_interface;
 
 	gboolean is_offline;	
@@ -143,6 +143,7 @@
 	CalendarOfflineHandler *offline_handler = data;
 
 	update_offline (offline_handler);
+	g_object_unref (client);
 }
 
 static void
@@ -171,6 +172,7 @@
 	}
 
 	cal_client_set_mode (client, CAL_MODE_REMOTE);
+	g_object_unref (client);
 }
 
 static void
@@ -188,7 +190,7 @@
 		update_offline (offline_handler);
 		g_object_unref (client);
 		return;		
-	}	
+	}
 }
 
 static void
@@ -256,6 +258,8 @@
 	offline_handler = CALENDAR_OFFLINE_HANDLER (object);
 	priv = offline_handler->priv;
 
+	g_object_unref (priv->client);
+	
 	if (priv->listener_interface != CORBA_OBJECT_NIL) {
 		CORBA_Environment ev;
 
Index: gui/e-calendar-table.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-calendar-table.c,v
retrieving revision 1.88
diff -u -r1.88 e-calendar-table.c
--- gui/e-calendar-table.c	25 Apr 2003 01:57:54 -0000	1.88
+++ gui/e-calendar-table.c	13 May 2003 15:51:11 -0000
@@ -135,6 +135,7 @@
 	GtkObjectClass *object_class;
 	GtkWidgetClass *widget_class;
 
+	parent_class = g_type_class_peek_parent (class);
 	object_class = (GtkObjectClass *) class;
 	widget_class = (GtkWidgetClass *) class;
 
@@ -533,8 +534,8 @@
 			  G_CALLBACK (selection_clear_event), cal_table);
 	g_signal_connect (cal_table->invisible, "selection_received",
 			  G_CALLBACK (selection_received), cal_table);
-	g_signal_connect (cal_table->invisible, "destroy",
-			  G_CALLBACK (invisible_destroyed), cal_table);
+	g_signal_connect_after (cal_table->invisible, "destroy",
+				G_CALLBACK (invisible_destroyed), cal_table);
 
 	cal_table->clipboard_selection = NULL;
 }
@@ -582,9 +583,11 @@
 
 	cal_table = E_CALENDAR_TABLE (object);
 
-	g_object_unref (cal_table->model);
-	cal_table->model = NULL;
-
+	if (cal_table->model) {
+		g_object_unref (cal_table->model);
+		cal_table->model = NULL;
+	}
+	
 	if (cal_table->invisible)
 		gtk_widget_destroy (cal_table->invisible);
 	if (cal_table->clipboard_selection) {
@@ -1175,7 +1178,6 @@
 static void
 invisible_destroyed (GtkWidget *invisible, ECalendarTable *cal_table)
 {
-	g_object_unref (cal_table->invisible);
 	cal_table->invisible = NULL;
 }
 
Index: gui/e-day-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-day-view.c,v
retrieving revision 1.189
diff -u -r1.189 e-day-view.c
--- gui/e-day-view.c	25 Apr 2003 01:57:54 -0000	1.189
+++ gui/e-day-view.c	13 May 2003 15:51:13 -0000
@@ -843,8 +843,8 @@
 			  G_CALLBACK (selection_clear_event), (gpointer) day_view);
 	g_signal_connect (day_view->invisible, "selection_received",
 			  G_CALLBACK (selection_received), (gpointer) day_view);
-	g_signal_connect (day_view->invisible, "destroy",
-			  G_CALLBACK (invisible_destroyed), (gpointer) day_view);
+	g_signal_connect_after (day_view->invisible, "destroy",
+				G_CALLBACK (invisible_destroyed), (gpointer) day_view);
 
 	day_view->clipboard_selection = NULL;
 
@@ -7574,7 +7574,6 @@
 static void
 invisible_destroyed (GtkWidget *invisible, EDayView *day_view)
 {
-	g_object_unref (day_view->invisible);
 	day_view->invisible = NULL;
 }
 
Index: gui/e-tasks.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-tasks.c,v
retrieving revision 1.49
diff -u -r1.49 e-tasks.c
--- gui/e-tasks.c	25 Apr 2003 01:57:54 -0000	1.49
+++ gui/e-tasks.c	13 May 2003 15:51:13 -0000
@@ -306,15 +306,17 @@
 	tasks = E_TASKS (object);
 	priv = tasks->priv;
 
-	if (priv->client) {
-		g_object_unref (priv->client);
-		priv->client = NULL;
+	if (priv) {
+		if (priv->client) {
+			g_object_unref (priv->client);
+			priv->client = NULL;
+		}
+		
+		g_free (priv);
+		tasks->priv = NULL;
+	
+		all_tasks = g_list_remove (all_tasks, tasks);
 	}
-
-	g_free (priv);
-	tasks->priv = NULL;
-
-	all_tasks = g_list_remove (all_tasks, tasks);
 
 	if (GTK_OBJECT_CLASS (parent_class)->destroy)
 		(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
Index: gui/e-week-view.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/e-week-view.c,v
retrieving revision 1.159
diff -u -r1.159 e-week-view.c
--- gui/e-week-view.c	25 Apr 2003 01:57:54 -0000	1.159
+++ gui/e-week-view.c	13 May 2003 15:51:15 -0000
@@ -434,8 +434,8 @@
 			  G_CALLBACK (selection_clear_event), (gpointer) week_view);
 	g_signal_connect (week_view->invisible, "selection_received",
 			  G_CALLBACK (selection_received), (gpointer) week_view);
-	g_signal_connect (week_view->invisible, "destroy",
-			  G_CALLBACK (invisible_destroyed), (gpointer) week_view);
+	g_signal_connect_after (week_view->invisible, "destroy",
+				G_CALLBACK (invisible_destroyed), (gpointer) week_view);
 
 	week_view->clipboard_selection = NULL;
 
@@ -4220,7 +4220,6 @@
 static void
 invisible_destroyed (GtkWidget *invisible, EWeekView *week_view)
 {
-	gtk_object_unref (GTK_OBJECT (week_view->invisible));
 	week_view->invisible = NULL;
 }
 
Index: gui/gnome-cal.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/gnome-cal.c,v
retrieving revision 1.239
diff -u -r1.239 gnome-cal.c
--- gui/gnome-cal.c	22 Apr 2003 21:15:40 -0000	1.239
+++ gui/gnome-cal.c	13 May 2003 15:51:16 -0000
@@ -916,56 +916,58 @@
 	gcal = GNOME_CALENDAR (object);
 	priv = gcal->priv;
 
-	free_categories (priv->cal_categories);
-	priv->cal_categories = NULL;
+	if (priv) {
+		free_categories (priv->cal_categories);
+		priv->cal_categories = NULL;
+
+		free_categories (priv->tasks_categories);
+		priv->tasks_categories = NULL;
+
+		/* Save the TaskPad layout. */
+		filename = g_strdup_printf ("%s/config/TaskPad", evolution_dir);
+		e_calendar_table_save_state (E_CALENDAR_TABLE (priv->todo), filename);
+		g_free (filename);
+
+		if (priv->dn_query) {
+			g_signal_handlers_disconnect_matched (priv->dn_query, G_SIGNAL_MATCH_DATA,
+							      0, 0, NULL, NULL, gcal);
+			g_object_unref (priv->dn_query);
+			priv->dn_query = NULL;
+		}
+
+		if (priv->sexp) {
+			g_free (priv->sexp);
+			priv->sexp = NULL;
+		}
+
+		if (priv->client) {
+			g_signal_handlers_disconnect_matched (priv->client, G_SIGNAL_MATCH_DATA,
+							      0, 0, NULL, NULL, gcal);
+			g_object_unref (priv->client);
+			priv->client = NULL;
+		}
+
+		if (priv->task_pad_client) {
+			g_signal_handlers_disconnect_matched (priv->task_pad_client, G_SIGNAL_MATCH_DATA,
+							      0, 0, NULL, NULL, gcal);
+			g_object_unref (priv->task_pad_client);
+			priv->task_pad_client = NULL;
+		}
+
+		if (priv->view_instance) {
+			g_object_unref (priv->view_instance);
+			priv->view_instance = NULL;
+		}
+
+		if (priv->view_menus) {
+			g_object_unref (priv->view_menus);
+			priv->view_menus = NULL;
+		}
 
-	free_categories (priv->tasks_categories);
-	priv->tasks_categories = NULL;
-
-	/* Save the TaskPad layout. */
-	filename = g_strdup_printf ("%s/config/TaskPad", evolution_dir);
-	e_calendar_table_save_state (E_CALENDAR_TABLE (priv->todo), filename);
-	g_free (filename);
-
-	if (priv->dn_query) {
-		g_signal_handlers_disconnect_matched (priv->dn_query, G_SIGNAL_MATCH_DATA,
-						      0, 0, NULL, NULL, gcal);
-		g_object_unref (priv->dn_query);
-		priv->dn_query = NULL;
-	}
-
-	if (priv->sexp) {
-		g_free (priv->sexp);
-		priv->sexp = NULL;
-	}
-
-	if (priv->client) {
-		g_signal_handlers_disconnect_matched (priv->client, G_SIGNAL_MATCH_DATA,
-						      0, 0, NULL, NULL, gcal);
-		g_object_unref (priv->client);
-		priv->client = NULL;
-	}
-
-	if (priv->task_pad_client) {
-		g_signal_handlers_disconnect_matched (priv->task_pad_client, G_SIGNAL_MATCH_DATA,
-						      0, 0, NULL, NULL, gcal);
-		g_object_unref (priv->task_pad_client);
-		priv->task_pad_client = NULL;
+		g_free (priv);
+		gcal->priv = NULL;
 	}
-
-	if (priv->view_instance) {
-		g_object_unref (priv->view_instance);
-		priv->view_instance = NULL;
-	}
-
-	if (priv->view_menus) {
-		g_object_unref (priv->view_menus);
-		priv->view_menus = NULL;
-	}
-
-	g_free (priv);
-	gcal->priv = NULL;
-
+	
 	if (GTK_OBJECT_CLASS (parent_class)->destroy)
 		(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
 }
? bonobo-ref.patch
? ui.txt
? ui2.txt
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.2721
diff -u -r1.2721 ChangeLog
--- ChangeLog	9 May 2003 17:11:08 -0000	1.2721
+++ ChangeLog	13 May 2003 15:51:38 -0000
@@ -1,3 +1,26 @@
+2003-05-13  JP Rosevear  <jpr ximian com>
+
+	* mail-local.h: add proto
+
+	* mail-local.c (storage_listener_startup): don't listen for
+	destruction, because we have a ref and it'll never happen
+	(mail_local_storage_shutdown): release and unref the local storage
+
+	* mail-display.c (retrieve_shell_view_interface_from_control):
+	return a new copy every time
+	(set_status_message): release and unref the shell view
+
+	* folder-browser.c (folder_browser_destroy): guard for multiple
+	destroys
+
+	* folder-browser-factory.c (control_activate): release and unref
+	the shell view
+	(control_destroy_cb): just remove the control from the list
+	(folder_browser_factory_new_control): don't weak ref the folder
+	browser
+
+	* component-factory.c (owner_unset_cb): shutdown local storage
+
 2003-05-08  Ettore Perazzoli  <ettore ximian com>
 
 	* mail-session.c (mail_session_set_interactive): Set the
Index: component-factory.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/component-factory.c,v
retrieving revision 1.322
diff -u -r1.322 component-factory.c
--- component-factory.c	7 Apr 2003 01:45:08 -0000	1.322
+++ component-factory.c	13 May 2003 15:51:39 -0000
@@ -925,6 +925,7 @@
 		empty_trash (NULL, NULL, NULL);
 	
 	unref_standard_folders ();
+	mail_local_storage_shutdown ();
 	mail_importer_uninit ();
 	
 	global_shell_client = NULL;
Index: folder-browser-factory.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/folder-browser-factory.c,v
retrieving revision 1.201
diff -u -r1.201 folder-browser-factory.c
--- folder-browser-factory.c	26 Mar 2003 21:24:45 -0000	1.201
+++ folder-browser-factory.c	13 May 2003 15:51:39 -0000
@@ -91,6 +91,7 @@
 {
 	GtkWidget *folder_browser;
 	Bonobo_UIContainer container;
+	GNOME_Evolution_ShellView svi;
 
 	container = bonobo_control_get_remote_ui_container (control, NULL);
 	bonobo_ui_component_set_container (uic, container, NULL);
@@ -110,7 +111,9 @@
 	
 	/*bonobo_ui_component_thaw (uic, NULL);*/
 	
-	folder_browser_set_shell_view (fb, fb_get_svi (control));
+	svi = fb_get_svi (control);
+	folder_browser_set_shell_view (fb, svi);
+	bonobo_object_release_unref (svi, NULL);
 	
 	folder_browser_reload (fb);
 	
@@ -158,32 +161,9 @@
 }
 
 static void
-control_destroy_cb (GtkObject *fb, GObject *deadbeef)
+control_destroy_cb (GtkObject *fb, GObject *control)
 {
-	gtk_object_destroy (fb);
-}
-
-static void
-browser_destroy_cb (BonoboControl *control, GObject *deadbeef)
-{
-	EIterator *it;
-	
-	/* We do this from browser_destroy_cb rather than
-	 * control_destroy_cb because currently, the controls
-	 * don't seem to all get destroyed properly at quit
-	 * time (but the widgets get destroyed by X). FIXME.
-	 */
-	
-	it = e_list_get_iterator (control_list);
-	while (e_iterator_is_valid (it)) {
-		if (e_iterator_get (it) == control) {
-			e_iterator_delete (it);
-			break;
-		}
-		e_iterator_next (it);
-	}
-	
-	g_object_unref (it);
+	e_list_remove (control_list, control);
 }
 
 BonoboControl *
@@ -210,7 +190,6 @@
 	g_signal_connect (control, "activate", G_CALLBACK (control_activate_cb), fb);
 	
 	g_object_weak_ref (G_OBJECT(control), (GWeakNotify) control_destroy_cb, fb);
-	g_object_weak_ref (G_OBJECT(fb), (GWeakNotify) browser_destroy_cb, control);
 	
 	if (!control_list)
 		control_list = e_list_new (NULL, NULL, NULL);
Index: folder-browser.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/folder-browser.c,v
retrieving revision 1.343
diff -u -r1.343 folder-browser.c
--- folder-browser.c	2 May 2003 16:07:17 -0000	1.343
+++ folder-browser.c	13 May 2003 15:51:40 -0000
@@ -199,8 +199,11 @@
 	}
 	
 	/* wait for all outstanding async events against us */
-	mail_async_event_destroy (folder_browser->async_event);
-
+	if (folder_browser->async_event) {
+		mail_async_event_destroy (folder_browser->async_event);
+		folder_browser->async_event = NULL;
+	}
+	
 	if (folder_browser->search_full) {
 		g_object_unref (folder_browser->search_full);
 		folder_browser->search_full = NULL;
Index: mail-display.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-display.c,v
retrieving revision 1.276
diff -u -r1.276 mail-display.c
--- mail-display.c	8 May 2003 17:01:55 -0000	1.276
+++ mail-display.c	13 May 2003 15:51:41 -0000
@@ -2570,14 +2570,11 @@
 	shell_view_interface = Bonobo_Unknown_queryInterface (control_frame,
 							      "IDL:GNOME/Evolution/ShellView:1.0",
 							      &ev);
-	CORBA_exception_free (&ev);
+
+	if (BONOBO_EX (&ev))
+		shell_view_interface = CORBA_OBJECT_NIL;
 	
-	if (shell_view_interface != CORBA_OBJECT_NIL)
-		g_object_set_data ((GObject *) control,
-				   "mail_threads_shell_view_interface",
-				   shell_view_interface);
-	else
-		g_warning ("Control frame doesn't have Evolution/ShellView.");
+	CORBA_exception_free (&ev);
 	
 	return shell_view_interface;
 }
@@ -2596,10 +2593,7 @@
 		
 		control = BONOBO_CONTROL (e_iterator_get (it));
 		
-		shell_view_interface = g_object_get_data ((GObject *) control, "mail_threads_shell_view_interface");
-		
-		if (shell_view_interface == CORBA_OBJECT_NIL)
-			shell_view_interface = retrieve_shell_view_interface_from_control (control);
+		shell_view_interface = retrieve_shell_view_interface_from_control (control);
 		
 		CORBA_exception_init (&ev);
 		
@@ -2612,6 +2606,8 @@
 		}
 		
 		CORBA_exception_free (&ev);
+
+		bonobo_object_release_unref (shell_view_interface, NULL);
 		
 		/* yeah we only set the first one.  Why?  Because it seems to leave
 		   random ones lying around otherwise.  Shrug. */
Index: mail-local.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-local.c,v
retrieving revision 1.130
diff -u -r1.130 mail-local.c
--- mail-local.c	25 Mar 2003 15:49:19 -0000	1.130
+++ mail-local.c	13 May 2003 15:51:41 -0000
@@ -1143,18 +1143,6 @@
 /* ** Local Storage Listener ****************************************************** */
 
 static void
-local_storage_destroyed_cb (EvolutionStorageListener *storage_listener,
-			    void *data)
-{
-	CORBA_Environment ev;
-
-	CORBA_exception_init (&ev);
-	bonobo_object_release_unref (data, &ev);
-	CORBA_exception_free (&ev);
-}
-
-
-static void
 local_storage_new_folder_cb (EvolutionStorageListener *storage_listener,
 			     const char *path,
 			     const GNOME_Evolution_Folder *folder,
@@ -1232,11 +1220,6 @@
 	corba_local_storage_listener = evolution_storage_listener_corba_objref (
 		local_storage_listener);
 
-	/* FIXME: is this supposed to be destroy? */
-	g_signal_connect(local_storage_listener,
-			 "destroyed",
-			 G_CALLBACK (local_storage_destroyed_cb),
-			 corba_storage);
 	g_signal_connect(local_storage_listener,
 			 "new_folder",
 			 G_CALLBACK (local_storage_new_folder_cb),
@@ -1272,6 +1255,13 @@
 	}
 
 	storage_listener_startup (shellclient);
+}
+
+void
+mail_local_storage_shutdown (void)
+{
+	bonobo_object_release_unref (local_corba_storage, NULL);
+	local_corba_storage = CORBA_OBJECT_NIL;
 }
 
 
Index: mail-local.h
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-local.h,v
retrieving revision 1.12
diff -u -r1.12 mail-local.h
--- mail-local.h	11 Sep 2002 04:27:23 -0000	1.12
+++ mail-local.h	13 May 2003 15:51:41 -0000
@@ -30,6 +30,7 @@
 #include <camel/camel-folder.h>
 
 void mail_local_storage_startup (EvolutionShellClient *shellclient, const char *evolution_path);
+void mail_local_storage_shutdown (void);
 
 void mail_local_reconfigure_folder(const char *uri, void (*done)(const char *uri, CamelFolder *folder, void *data), void *done_data);
 
? bonobo-ref.patch
? old.txt
? old2.txt
? old3.txt
? ref.txt
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/shell/ChangeLog,v
retrieving revision 1.1271
diff -u -r1.1271 ChangeLog
--- ChangeLog	9 May 2003 15:00:46 -0000	1.1271
+++ ChangeLog	13 May 2003 15:52:08 -0000
@@ -1,3 +1,25 @@
+2003-05-12  JP Rosevear  <jpr ximian com>
+
+	* e-shell.c (save_settings_for_component): release the interface
+	if we got it
+
+	* e-shell-view.c: include bonobo-exception.h
+	(impl_dispose): release and unref the shell view corba interface
+	(init): init to CORBA_OBJECT_NIL
+	(e_shell_view_get_corba_interface): return the corba interface
+	(setup_corba_interface): add as an interface and then query to get
+	it back
+	(get_view_for_uri): release and unref the control once we create
+	the widget with it
+
+	* e-corba-storage.c (storage_listener_servant_new): don't ref ourselves
+	(storage_listener_servant_free): don't unref ourselves
+	(impl_dispose): free the servant info
+
+	* e-corba-storage-registry.c
+	(impl_StorageRegistry_getStorageByName): we need to ref as well as
+	duplicate since we didn't create the storage here
+
 2003-05-09  Jeremy Katz  <katzj redhat com>
 
 	* main.c: Add a #include to fix a warning.
Index: e-corba-storage-registry.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-corba-storage-registry.c,v
retrieving revision 1.30
diff -u -r1.30 e-corba-storage-registry.c
--- e-corba-storage-registry.c	13 Jan 2003 18:51:36 -0000	1.30
+++ e-corba-storage-registry.c	13 May 2003 15:52:08 -0000
@@ -193,10 +193,9 @@
 		return CORBA_OBJECT_NIL;
 	}
 
-	corba_storage = CORBA_Object_duplicate (e_corba_storage_get_corba_objref
-						(E_CORBA_STORAGE (storage)), ev);
+	corba_storage = e_corba_storage_get_corba_objref (E_CORBA_STORAGE (storage));
 
-	return corba_storage;
+	return bonobo_object_dup_ref (corba_storage, NULL);
 }
 
 static void
Index: e-corba-storage.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-corba-storage.c,v
retrieving revision 1.56
diff -u -r1.56 e-corba-storage.c
--- e-corba-storage.c	25 Apr 2003 17:03:51 -0000	1.56
+++ e-corba-storage.c	13 May 2003 15:52:08 -0000
@@ -77,7 +77,6 @@
 
 	servant->servant.vepv = &storage_listener_vepv;
 
-	g_object_ref (corba_storage);
 	servant->storage = E_STORAGE (corba_storage);
 
 	return servant;
@@ -86,8 +85,6 @@
 static void
 storage_listener_servant_free (StorageListenerServant *servant)
 {
-	g_object_unref (servant->storage);
-
 	g_free (servant);
 }
 
@@ -272,6 +269,7 @@
 
 		CORBA_free (object_id);
 
+		storage_listener_servant_free (priv->storage_listener_servant);
 		priv->storage_listener_servant = NULL;
 	}
 
Index: e-shell-user-creatable-items-handler.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-shell-user-creatable-items-handler.c,v
retrieving revision 1.27
diff -u -r1.27 e-shell-user-creatable-items-handler.c
--- e-shell-user-creatable-items-handler.c	15 Apr 2003 21:27:08 -0000	1.27
+++ e-shell-user-creatable-items-handler.c	13 May 2003 15:52:08 -0000
@@ -598,6 +598,8 @@
 	bonobo_ui_component_object_set (ui_component, "/Toolbar/NewComboButton",
 					BONOBO_OBJREF (control), NULL);
 
+	bonobo_object_unref (control);
+	
 	g_object_set_data (G_OBJECT (shell_view), COMBO_BUTTON_WIDGET_KEY, combo_button);
 
 	tooltips = gtk_tooltips_new ();
@@ -679,6 +681,7 @@
 	g_slist_free (priv->components);
 	priv->components = NULL;
 
+	
 	(* G_OBJECT_CLASS (parent_class)->dispose) (object);
 }
 
Index: e-shell-view.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-shell-view.c,v
retrieving revision 1.283
diff -u -r1.283 e-shell-view.c
--- e-shell-view.c	8 May 2003 21:54:58 -0000	1.283
+++ e-shell-view.c	13 May 2003 15:52:09 -0000
@@ -66,6 +66,7 @@
 #include <gtk/gtkscrolledwindow.h>
 #include <gconf/gconf-client.h>
 
+#include <bonobo/bonobo-exception.h>
 #include <bonobo/bonobo-socket.h>
 #include <bonobo/bonobo-ui-util.h>
 #include <bonobo/bonobo-ui-container.h>
@@ -91,7 +92,7 @@
 
 	/* EvolutionShellView Bonobo object for implementing the
            Evolution::ShellView interface.  */
-	EvolutionShellView *corba_interface;
+	GNOME_Evolution_ShellView corba_interface;
 
 	/* The UI handler & container.  */
 	BonoboUIComponent *ui_component;
@@ -1465,7 +1466,7 @@
 	}
 
 	if (priv->corba_interface != NULL) {
-		bonobo_object_unref (BONOBO_OBJECT (priv->corba_interface));
+		bonobo_object_release_unref (priv->corba_interface, NULL);
 		priv->corba_interface = NULL;
 	}
 
@@ -1582,7 +1583,7 @@
 	priv = g_new (EShellViewPrivate, 1);
 
 	priv->shell                   = NULL;
-	priv->corba_interface         = NULL;
+	priv->corba_interface         = CORBA_OBJECT_NIL;
 	priv->ui_component            = NULL;
 	priv->history                 = e_history_new ((EHistoryItemFreeFunc) g_free);
 	priv->uri                     = NULL;
@@ -1900,7 +1901,7 @@
 
 	priv = shell_view->priv;
 
-	return bonobo_object_corba_objref (BONOBO_OBJECT (priv->corba_interface));
+	return priv->corba_interface;
 }
 
 
@@ -2167,7 +2168,8 @@
 	EShellViewPrivate *priv;
 	BonoboControlFrame *control_frame;
 	EvolutionShellView *corba_interface;
-
+	CORBA_Environment ev;
+	
 	g_return_if_fail (control != NULL);
 
 	priv = shell_view->priv;
@@ -2191,8 +2193,14 @@
 	bonobo_object_add_interface (BONOBO_OBJECT (control_frame),
 				     BONOBO_OBJECT (corba_interface));
 
-	bonobo_object_ref (BONOBO_OBJECT (corba_interface));
-	priv->corba_interface = corba_interface;
+
+	CORBA_exception_init (&ev);
+	priv->corba_interface = Bonobo_Unknown_queryInterface (BONOBO_OBJREF (control_frame),
+							       "IDL:GNOME/Evolution/ShellView:1.0",
+							       &ev);
+	if (BONOBO_EX (&ev))
+		priv->corba_interface = CORBA_OBJECT_NIL;
+	CORBA_exception_free (&ev);
 }
 
 
@@ -2339,6 +2347,7 @@
 
 	container = bonobo_ui_component_get_container (priv->ui_component);
 	control = bonobo_widget_new_control_from_objref (corba_control, container);
+	bonobo_object_release_unref (corba_control, NULL);
 
 	socket = find_socket (GTK_CONTAINER (control));
 	destroy_connection_id = g_signal_connect (socket, "destroy",
Index: e-shell.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-shell.c,v
retrieving revision 1.213
diff -u -r1.213 e-shell.c
--- e-shell.c	15 Apr 2003 21:27:08 -0000	1.213
+++ e-shell.c	13 May 2003 15:52:10 -0000
@@ -1630,6 +1630,9 @@
 
 	g_free (prefix);
 
+	if (retval)
+		bonobo_object_release_unref (session_interface, NULL);
+	
 	CORBA_exception_free (&ev);
 
 	return retval;
Index: main.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/main.c,v
retrieving revision 1.121
diff -u -r1.121 main.c
--- main.c	9 May 2003 15:00:46 -0000	1.121
+++ main.c	13 May 2003 15:52:10 -0000
@@ -627,5 +627,7 @@
 
 	bonobo_main ();
 
+	bonobo_debug_shutdown ();
+	
 	return 0;
 }
? bonobo-ref.patch
Index: gal-view-menus.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/menus/gal-view-menus.c,v
retrieving revision 1.40
diff -u -r1.40 gal-view-menus.c
--- gal-view-menus.c	28 Apr 2003 17:48:02 -0000	1.40
+++ gal-view-menus.c	13 May 2003 15:50:26 -0000
@@ -148,6 +148,9 @@
 
 	gal_view_menus_unmerge (gvm, NULL);
 
+	if (gvm->priv->component)
+		bonobo_object_unref (gvm->priv->component);
+	
 	if (gvm->priv->define_views_dialog)
 		g_object_weak_unref (G_OBJECT (gvm->priv->define_views_dialog), clear_define_views_dialog, gvm);
 
? bonobo-ref.patch
Index: e-combo-button.c
===================================================================
RCS file: /cvs/gnome/evolution/widgets/misc/e-combo-button.c,v
retrieving revision 1.12
diff -u -r1.12 e-combo-button.c
--- e-combo-button.c	9 May 2003 16:34:04 -0000	1.12
+++ e-combo-button.c	13 May 2003 15:50:31 -0000
@@ -248,18 +248,21 @@
 	combo_button = E_COMBO_BUTTON (object);
 	priv = combo_button->priv;
 
-	if (priv->arrow_pixmap != NULL) {
-		gtk_widget_destroy (priv->arrow_pixmap);
-		priv->arrow_pixmap = NULL;
-	}
+	if (priv) {
+		if (priv->arrow_pixmap != NULL) {
+			gtk_widget_destroy (priv->arrow_pixmap);
+			priv->arrow_pixmap = NULL;
+		}
+		
+		if (priv->icon != NULL) {
+			g_object_unref (priv->icon);
+			priv->icon = NULL;
+		}
 
-	if (priv->icon != NULL) {
-		g_object_unref (priv->icon);
-		priv->icon = NULL;
+		g_free (priv);
+		combo_button->priv = NULL;
 	}
-
-	g_free (priv);
-
+	
 	(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
 }
 


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