Index: e-shell-view.c
===================================================================
RCS file: /cvs/gnome/evolution/shell/e-shell-view.c,v
retrieving revision 1.289
diff -u -p -r1.289 e-shell-view.c
--- e-shell-view.c	24 Apr 2006 05:03:49 -0000	1.289
+++ e-shell-view.c	9 Oct 2006 15:12:39 -0000
@@ -43,25 +43,26 @@ static void
 impl_ShellView_setTitle(PortableServer_Servant _servant, const CORBA_char *id, const CORBA_char * title, CORBA_Environment * ev)
 {
 	EShellView *esw = (EShellView *)bonobo_object_from_servant(_servant);
-	char *tmp = g_strdup_printf("%s - Evolution", title);
 
-	e_shell_window_set_title(esw->window, id, tmp);
-	g_free(tmp);
+	if (esw->window) {
+		char *tmp = g_strdup_printf("%s - Evolution", title);
+		e_shell_window_set_title(esw->window, id, tmp);
+		g_free(tmp);
+	}
 }
 
 static void
 impl_ShellView_setComponent(PortableServer_Servant _servant, const CORBA_char *id, CORBA_Environment * ev)
 {
 	EShellView *esw = (EShellView *)bonobo_object_from_servant(_servant);
-
-	e_shell_window_switch_to_component(esw->window, id);
+	
+	if (esw->window)
+		e_shell_window_switch_to_component(esw->window, id);
 }
 
 static void
 impl_dispose (GObject *object)
 {
-	/*EShellView *esv = (EShellView *)object;*/
-
 	((GObjectClass *)parent_class)->dispose(object);
 }
 
@@ -93,14 +94,23 @@ e_shell_view_init (EShellView *shell)
 {
 }
 
-EShellView *e_shell_view_new(struct _EShellWindow *window)
+static gboolean
+e_shell_view_on_window_destroy (GObject *object, gpointer data)
 {
-	EShellView *new = g_object_new (e_shell_view_get_type (), NULL);
+	EShellView *esv = (EShellView *)data;
+        esv->window = NULL;
+        return TRUE;
+}
 
-	/* TODO: listen to destroy? */
-	new->window = window;
+EShellView *e_shell_view_new(struct _EShellWindow *window)
+{
+	EShellView *esv = g_object_new (e_shell_view_get_type (), NULL);
 
-	return new;
+	esv->window = window;
+	g_signal_connect_object (window, "destroy", 
+				 e_shell_view_on_window_destroy, 
+				 esv, 0);
+	return esv;
 }
 
 BONOBO_TYPE_FUNC_FULL (EShellView, GNOME_Evolution_ShellView, bonobo_object_get_type(), e_shell_view)
