Index: calendar/gui/e-memos.c
===================================================================
--- calendar/gui/e-memos.c	(revision 34363)
+++ calendar/gui/e-memos.c	(working copy)
@@ -749,6 +749,8 @@
 
 	source = g_object_ref (e_cal_get_source (client));
 
+	memos_component_add_died_source (NULL, e_source_peek_uid (source));
+
 	priv->clients_list = g_list_remove (priv->clients_list, client);
 	g_hash_table_remove (priv->clients,  e_source_peek_uid (source));
 
@@ -781,6 +783,7 @@
 		set_status_message (memos, _("Loading memos"));
 		model = e_memo_table_get_model (E_MEMO_TABLE (priv->memos_view));
 		e_cal_model_add_client (model, ecal);
+		memos_component_remove_died_source (NULL, e_source_peek_uid (source));
 
 		set_timezone (memos);
 		set_status_message (memos, NULL);
Index: calendar/gui/tasks-component.c
===================================================================
--- calendar/gui/tasks-component.c	(revision 34363)
+++ calendar/gui/tasks-component.c	(working copy)
@@ -110,6 +110,7 @@
 
 	ESourceList *source_list;
 	GSList *source_selection;
+	GSList *died_sources;
 
 	GList *views;
 	
@@ -274,7 +275,8 @@
 static void
 update_uris_for_selection (TasksComponentView *component_view)
 {
-	GSList *selection, *l, *uids_selected = NULL;
+	GSList *selection, *l, *uids_selected = NULL, *old_selected;
+	TasksComponent *component;
 	
 	selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (component_view->source_selector));
 	
@@ -292,12 +294,26 @@
 		uids_selected = g_slist_append (uids_selected, (char *)e_source_peek_uid (selected_source));
 	}
 
+	component = tasks_component_peek ();
+	old_selected = calendar_config_get_tasks_selected ();
+
+	/* add back those which has been selected before and are closed by crash */
+	for (l = old_selected; l != NULL; l = l->next) {
+		if (cal_comp_util_is_in_died_sources (component->priv->died_sources, l->data))
+			uids_selected = g_slist_append (uids_selected, l->data);
+	}
+
 	e_source_selector_free_selection (component_view->source_selection);
 	component_view->source_selection = selection;
 
 	/* Save the selection for next time we start up */
 	calendar_config_set_tasks_selected (uids_selected);
 	g_slist_free (uids_selected);
+
+	if (old_selected) {
+		g_slist_foreach (old_selected, (GFunc) g_free, NULL);
+		g_slist_free (old_selected);
+	}
 }
 
 static void
@@ -1337,6 +1353,9 @@
 	g_list_free (priv->notifications);
 	priv->notifications = NULL;
 
+	cal_comp_util_free_died_sources (priv->died_sources);
+	priv->died_sources = NULL;
+
 	(* G_OBJECT_CLASS (parent_class)->dispose) (object);
 }
 
@@ -1433,4 +1452,46 @@
 	return component->priv->source_list;	
 }
 
+/**
+ * tasks_component_add_died_source
+ * We track list of died sources to not save them state (checked/unchecked).
+ * @param component To which component put new source_uid. Can be NULL, in
+ *           that case will be used one from @ref tasks_component_peek.
+ * @param source_uid UID of died source.
+ **/
+void
+tasks_component_add_died_source (TasksComponent *component, const char *source_uid)
+{
+	g_return_if_fail (source_uid != NULL);
+
+	if (!component)
+		component = tasks_component_peek ();
+
+	g_return_if_fail (component != NULL);
+
+	component->priv->died_sources = cal_comp_util_add_died_source (component->priv->died_sources, source_uid);
+}
+
+/**
+ * tasks_component_remove_died_source
+ * This is a pair function for @ref tasks_component_add_died_source, if we have
+ * source_id in a list of died sources, then this function will remove it from there.
+ * When it isn't there, then this does nothing.
+ * @param component To which component put new source_uid. Can be NULL, in
+ *           that case will be used one from @ref tasks_component_peek.
+ * @param source_uid UID of died source.
+ **/
+void
+tasks_component_remove_died_source (TasksComponent *component, const char *source_uid)
+{
+	g_return_if_fail (source_uid != NULL);
+
+	if (!component)
+		component = tasks_component_peek ();
+
+	g_return_if_fail (component != NULL);
+
+	component->priv->died_sources = cal_comp_util_remove_died_source (component->priv->died_sources, source_uid);
+}
+
 BONOBO_TYPE_FUNC_FULL (TasksComponent, GNOME_Evolution_Component, PARENT_TYPE, tasks_component)
Index: calendar/gui/tasks-component.h
===================================================================
--- calendar/gui/tasks-component.h	(revision 34363)
+++ calendar/gui/tasks-component.h	(working copy)
@@ -60,4 +60,7 @@
 const char       *tasks_component_peek_config_directory (TasksComponent *component);
 ESourceList      *tasks_component_peek_source_list (TasksComponent *component);
 
+void              tasks_component_add_died_source (TasksComponent *component, const char *source_uid);
+void              tasks_component_remove_died_source (TasksComponent *component, const char *source_uid);
+
 #endif /* _TASKS_COMPONENT_H_ */
Index: calendar/gui/gnome-cal.c
===================================================================
--- calendar/gui/gnome-cal.c	(revision 34363)
+++ calendar/gui/gnome-cal.c	(working copy)
@@ -2654,6 +2654,7 @@
 			model = e_calendar_view_get_model (priv->views[i]);
 			e_cal_model_add_client (model, ecal);
 		}
+		calendar_component_remove_died_source (NULL, e_source_peek_uid (source));
 
 		/* update date navigator query */
 		update_query (gcal);
@@ -2667,6 +2668,7 @@
 		g_free (msg);
 
 		e_cal_model_add_client (e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)), ecal);
+		calendar_component_remove_died_source (NULL, e_source_peek_uid (source));
 
 		e_calendar_table_set_status_message (E_CALENDAR_TABLE (priv->todo), NULL, -1);
 		break;
@@ -2675,6 +2677,7 @@
 		e_memo_table_set_status_message (E_MEMO_TABLE (priv->memo), msg);
 		g_free (msg);
 		e_cal_model_add_client (e_memo_table_get_model (E_MEMO_TABLE (priv->memo)), ecal);
+		calendar_component_remove_died_source (NULL, e_source_peek_uid (source));
 		e_memo_table_set_status_message (E_MEMO_TABLE (priv->memo), NULL);
 		break;		
 	default:
@@ -2845,7 +2848,9 @@
 	/* Make sure the source doesn't go away on us since we use it below */
 	source_type = e_cal_get_source_type (ecal);
 	source = g_object_ref (e_cal_get_source (ecal));	
-		
+
+	calendar_component_add_died_source (NULL, e_source_peek_uid (source));
+
 	priv->clients_list[source_type] = g_list_remove (priv->clients_list[source_type], ecal);
 	g_hash_table_remove (priv->clients[source_type], e_source_peek_uid (source));
 
Index: calendar/gui/e-tasks.c
===================================================================
--- calendar/gui/e-tasks.c	(revision 34363)
+++ calendar/gui/e-tasks.c	(working copy)
@@ -862,6 +862,8 @@
 
 	source = g_object_ref (e_cal_get_source (client));
 
+	tasks_component_add_died_source (NULL, e_source_peek_uid (source));
+
 	priv->clients_list = g_list_remove (priv->clients_list, client);
 	g_hash_table_remove (priv->clients,  e_source_peek_uid (source));
 
@@ -894,6 +896,7 @@
 		set_status_message (tasks, _("Loading tasks"));
 		model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view));
 		e_cal_model_add_client (model, ecal);
+		tasks_component_remove_died_source (NULL, e_source_peek_uid (source));
 
 		set_status_message (tasks, NULL);
 		break;
Index: calendar/gui/calendar-component.c
===================================================================
--- calendar/gui/calendar-component.c	(revision 34363)
+++ calendar/gui/calendar-component.c	(working copy)
@@ -120,6 +120,7 @@
 	ESourceList *source_list;
 	ESourceList *task_source_list;
 	ESourceList *memo_source_list;
+	GSList *died_sources;
 
 	GList *views;
 
@@ -357,7 +358,8 @@
 static void
 update_uris_for_selection (CalendarComponentView *component_view)
 {
-	GSList *selection, *l, *uids_selected = NULL;
+	GSList *selection, *l, *uids_selected = NULL, *old_selected;
+	CalendarComponent *component;
 	
 	selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (component_view->source_selector));
 
@@ -378,9 +380,23 @@
 	e_source_selector_free_selection (component_view->source_selection);
 	component_view->source_selection = selection;
 
+	component = calendar_component_peek ();
+	old_selected = calendar_config_get_calendars_selected ();
+
+	/* add back those which has been selected before and are closed by crash */
+	for (l = old_selected; l != NULL; l = l->next) {
+		if (cal_comp_util_is_in_died_sources (component->priv->died_sources, l->data))
+			uids_selected = g_slist_append (uids_selected, l->data);
+	}
+
 	/* Save the selection for next time we start up */
 	calendar_config_set_calendars_selected (uids_selected);
 	g_slist_free (uids_selected);
+
+	if (old_selected) {
+		g_slist_foreach (old_selected, (GFunc) g_free, NULL);
+		g_slist_free (old_selected);
+	}
 }
 
 static void
@@ -1673,6 +1689,9 @@
 	g_list_free (priv->notifications);
 	priv->notifications = NULL;
 
+	cal_comp_util_free_died_sources (priv->died_sources);
+	priv->died_sources = NULL;
+
 	(* G_OBJECT_CLASS (parent_class)->dispose) (object);
 }
 
@@ -1785,4 +1804,46 @@
 	return component->priv->source_list;
 }
 
+/**
+ * calendar_component_add_died_source
+ * We track list of died sources to not save them state (checked/unchecked).
+ * @param component To which component put new source_uid. Can be NULL, in
+ *           that case will be used one from @ref calendar_component_peek.
+ * @param source_uid UID of died source.
+ **/
+void
+calendar_component_add_died_source (CalendarComponent *component, const char *source_uid)
+{
+	g_return_if_fail (source_uid != NULL);
+
+	if (!component)
+		component = calendar_component_peek ();
+
+	g_return_if_fail (component != NULL);
+
+	component->priv->died_sources = cal_comp_util_add_died_source (component->priv->died_sources, source_uid);
+}
+
+/**
+ * calendar_component_remove_died_source
+ * This is a pair function for @ref calendar_component_add_died_source, if we have
+ * source_id in a list of died sources, then this function will remove it from there.
+ * When it isn't there, then this does nothing.
+ * @param component To which component put new source_uid. Can be NULL, in
+ *           that case will be used one from @ref calendar_component_peek.
+ * @param source_uid UID of died source.
+ **/
+void
+calendar_component_remove_died_source (CalendarComponent *component, const char *source_uid)
+{
+	g_return_if_fail (source_uid != NULL);
+
+	if (!component)
+		component = calendar_component_peek ();
+
+	g_return_if_fail (component != NULL);
+
+	component->priv->died_sources = cal_comp_util_remove_died_source (component->priv->died_sources, source_uid);
+}
+
 BONOBO_TYPE_FUNC_FULL (CalendarComponent, GNOME_Evolution_Component, PARENT_TYPE, calendar_component)
Index: calendar/gui/calendar-component.h
===================================================================
--- calendar/gui/calendar-component.h	(revision 34363)
+++ calendar/gui/calendar-component.h	(working copy)
@@ -61,5 +61,7 @@
 const char       *calendar_component_peek_config_directory  (CalendarComponent *component);
 ESourceList      *calendar_component_peek_source_list       (CalendarComponent *component);
 
+void              calendar_component_add_died_source (CalendarComponent *component, const char *source_uid);
+void              calendar_component_remove_died_source (CalendarComponent *component, const char *source_uid);
 
 #endif /* _CALENDAR_COMPONENT_H_ */
Index: calendar/gui/memos-component.c
===================================================================
--- calendar/gui/memos-component.c	(revision 34363)
+++ calendar/gui/memos-component.c	(working copy)
@@ -111,6 +111,7 @@
 
 	ESourceList *source_list;
 	GSList *source_selection;
+	GSList *died_sources;
 
 	GList *views;
 	
@@ -278,7 +279,8 @@
 static void
 update_uris_for_selection (MemosComponentView *component_view)
 {
-	GSList *selection, *l, *uids_selected = NULL;
+	GSList *selection, *l, *uids_selected = NULL, *old_selected;
+	MemosComponent *component;
 	
 	selection = e_source_selector_get_selection (E_SOURCE_SELECTOR (component_view->source_selector));
 	
@@ -299,9 +301,23 @@
 	e_source_selector_free_selection (component_view->source_selection);
 	component_view->source_selection = selection;
 
+	component = memos_component_peek ();
+	old_selected = calendar_config_get_memos_selected ();
+
+	/* add back those which has been selected before and are closed by crash */
+	for (l = old_selected; l != NULL; l = l->next) {
+		if (cal_comp_util_is_in_died_sources (component->priv->died_sources, l->data))
+			uids_selected = g_slist_append (uids_selected, l->data);
+	}
+
 	/* Save the selection for next time we start up */
 	calendar_config_set_memos_selected (uids_selected);
 	g_slist_free (uids_selected);
+
+	if (old_selected) {
+		g_slist_foreach (old_selected, (GFunc) g_free, NULL);
+		g_slist_free (old_selected);
+	}
 }
 
 static void
@@ -1271,6 +1287,9 @@
 	g_list_free (priv->notifications);
 	priv->notifications = NULL;
 
+	cal_comp_util_free_died_sources (priv->died_sources);
+	priv->died_sources = NULL;
+
 	(* G_OBJECT_CLASS (parent_class)->dispose) (object);
 }
 
@@ -1366,4 +1385,46 @@
 	return component->priv->source_list;	
 }
 
+/**
+ * memos_component_add_died_source
+ * We track list of died sources to not save them state (checked/unchecked).
+ * @param component To which component put new source_uid. Can be NULL, in
+ *           that case will be used one from @ref memos_component_peek.
+ * @param source_uid UID of died source.
+ **/
+void
+memos_component_add_died_source (MemosComponent *component, const char *source_uid)
+{
+	g_return_if_fail (source_uid != NULL);
+
+	if (!component)
+		component = memos_component_peek ();
+
+	g_return_if_fail (component != NULL);
+
+	component->priv->died_sources = cal_comp_util_add_died_source (component->priv->died_sources, source_uid);
+}
+
+/**
+ * memos_component_remove_died_source
+ * This is a pair function for @ref memos_component_add_died_source, if we have
+ * source_id in a list of died sources, then this function will remove it from there.
+ * When it isn't there, then this does nothing.
+ * @param component To which component put new source_uid. Can be NULL, in
+ *           that case will be used one from @ref memos_component_peek.
+ * @param source_uid UID of died source.
+ **/
+void
+memos_component_remove_died_source (MemosComponent *component, const char *source_uid)
+{
+	g_return_if_fail (source_uid != NULL);
+
+	if (!component)
+		component = memos_component_peek ();
+
+	g_return_if_fail (component != NULL);
+
+	component->priv->died_sources = cal_comp_util_remove_died_source (component->priv->died_sources, source_uid);
+}
+
 BONOBO_TYPE_FUNC_FULL (MemosComponent, GNOME_Evolution_Component, PARENT_TYPE, memos_component)
Index: calendar/gui/memos-component.h
===================================================================
--- calendar/gui/memos-component.h	(revision 34363)
+++ calendar/gui/memos-component.h	(working copy)
@@ -61,4 +61,7 @@
 const char       *memos_component_peek_config_directory (MemosComponent *component);
 ESourceList      *memos_component_peek_source_list (MemosComponent *component);
 
+void              memos_component_add_died_source (MemosComponent *component, const char *source_uid);
+void              memos_component_remove_died_source (MemosComponent *component, const char *source_uid);
+
 #endif /* _MEMOS_COMPONENT_H_ */
Index: calendar/gui/comp-util.c
===================================================================
--- calendar/gui/comp-util.c	(revision 34363)
+++ calendar/gui/comp-util.c	(working copy)
@@ -432,3 +432,82 @@
 
 	return num_icons;
 }
+
+/**
+ * cal_comp_util_add_died_source
+ * Adds a source UID to the list of died sources if it is not there yet.
+ * @param died_sources List of died sources, where to add this one.
+ * @param source_uid UID of the source of our interest.
+ * @return New start of the list of died sources! So be sure you store it.
+ **/
+GSList *
+cal_comp_util_add_died_source (GSList *died_sources, const char *source_uid)
+{
+	g_return_val_if_fail (source_uid != NULL, died_sources);
+
+	if (cal_comp_util_is_in_died_sources (died_sources, source_uid) != NULL)
+		return died_sources;
+
+	return g_slist_prepend (died_sources, g_strdup (source_uid));
+}
+
+/**
+ * cal_comp_util_remove_died_source
+ * Removes a source UID from the list of died sources if it is there.
+ * @param died_sources List of died sources, where to remove this one.
+ * @param source_uid UID of the source of our interest.
+ * @return New start of the list of died sources! So be sure you store it.
+ **/
+GSList *
+cal_comp_util_remove_died_source (GSList *died_sources, const char *source_uid)
+{
+	GSList *p;
+
+	g_return_val_if_fail (source_uid != NULL, died_sources);
+
+	p  = cal_comp_util_is_in_died_sources (died_sources, source_uid);
+
+	if (p != NULL) {
+		g_free (p->data);
+		return g_slist_delete_link (died_sources, p);
+	}
+
+	return died_sources;
+}
+
+/**
+ * cal_comp_util_is_in_died_sources
+ * Looks for a UID of the source in a list.
+ * @param died_sources List of died sources, where to look for.
+ * @param source_uid UID of the source of our interest.
+ * @return When found, then a pointer to the list item in which is that UID or NULL.
+ **/
+GSList *
+cal_comp_util_is_in_died_sources (GSList *died_sources, const char *source_uid)
+{
+	GSList *l;
+
+	g_return_val_if_fail (source_uid != NULL, NULL);
+	
+	for (l = died_sources; l != NULL; l = l->next) {
+		if (l->data && 0 == strcmp (l->data, source_uid))
+			break;
+	}
+
+	return l;
+}
+
+/**
+ * cal_comp_util_free_died_sources
+ * Frees whole list of died sources previously allocated with @ref cal_comp_util_add_died_source.
+ * @param died_sources List of died sources to free.
+ **/
+void
+cal_comp_util_free_died_sources (GSList *died_sources)
+{
+	if (died_sources == NULL)
+		return;
+
+	g_slist_foreach (died_sources, (GFunc) g_free, NULL);
+	g_slist_free (died_sources);
+}
Index: calendar/gui/comp-util.h
===================================================================
--- calendar/gui/comp-util.h	(revision 34363)
+++ calendar/gui/comp-util.h	(working copy)
@@ -47,4 +47,10 @@
 ECalComponent *cal_comp_task_new_with_defaults (ECal *client);
 ECalComponent *cal_comp_memo_new_with_defaults (ECal *client);
 
+/* Support for tracking died sources */
+GSList *cal_comp_util_add_died_source    (GSList *died_sources, const char *source_uid);
+GSList *cal_comp_util_remove_died_source (GSList *died_sources, const char *source_uid);
+GSList *cal_comp_util_is_in_died_sources (GSList *died_sources, const char *source_uid);
+void    cal_comp_util_free_died_sources  (GSList *died_sources);
+
 #endif
Index: calendar/ChangeLog
===================================================================
--- calendar/ChangeLog	(revision 34364)
+++ calendar/ChangeLog	(working copy)
@@ -1,3 +1,36 @@
+2007-10-11  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #305322
+
+	* gui/comp-util.h:
+	* gui/comp-util.c: (cal_comp_util_add_died_source),
+	(cal_comp_util_remove_died_source), (cal_comp_util_is_in_died_sources),
+	(cal_comp_util_free_died_sources):
+	New helper functions to work with died sources.
+	* gui/tasks-component.h: (tasks_component_add_died_source),
+	(tasks_component_remove_died_source):
+	* gui/tasks-component.c: (struct _TasksComponentPrivate),
+	(impl_dispose), (update_uris_for_selection),
+	(tasks_component_add_died_source),
+	(tasks_component_remove_died_source):
+	* gui/calendar-component.h: (calendar_component_add_died_source),
+	(calendar_component_remove_died_source):
+	* gui/calendar-component.c: (struct _CalendarComponentPrivate),
+	(update_uris_for_selection), (impl_dispose),
+	(calendar_component_add_died_source),
+	(calendar_component_remove_died_source):
+	* gui/memos-component.h: (memos_component_add_died_source),
+	(memos_component_remove_died_source):
+	* gui/memos-component.c: (struct _MemosComponentPrivate),
+	(update_uris_for_selection), (impl_dispose),
+	(memos_component_add_died_source),
+	(memos_component_remove_died_source):
+	Added support to track died sources in each component.
+	* gui/gnome-cal.c: (client_cal_opened_cb), (backend_died_cb):
+	* gui/e-tasks.c: (backend_died_cb), (client_cal_opened_cb):
+	* gui/e-memos.c: (backend_died_cb), (client_cal_opened_cb):
+	Marking sources as died/reincarnated in each component.
+
 2007-10-09  Milan Crha  <mcrha@redhat.com>
 
 	** Fix for bug #324526
