Index: libedataserverui/e-name-selector-entry.c
===================================================================
--- libedataserverui/e-name-selector-entry.c	(revision 9438)
+++ libedataserverui/e-name-selector-entry.c	(working copy)
@@ -1445,6 +1445,59 @@ entry_activate (ENameSelectorEntry *name
 	priv->is_completing = FALSE;
 }
 
+static void
+sanitize_entry (ENameSelectorEntry *name_selector_entry)
+{
+	int n;
+	GList *l, *known, *del = NULL;
+	const gchar *entry_text = gtk_entry_get_text (GTK_ENTRY (name_selector_entry));
+	GString *str = g_string_new ("");
+
+	g_signal_handlers_block_matched (name_selector_entry, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
+	g_signal_handlers_block_matched (name_selector_entry->destination_store, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
+
+	known = e_destination_store_list_destinations (name_selector_entry->destination_store);
+	for (l = known, n = 0; l != NULL; l = l->next, n++) {
+		EDestination *dest = l->data;
+
+		if (!dest || !e_destination_get_address (dest))
+			del = g_list_prepend (del, GINT_TO_POINTER (n));
+		else {
+			gint start, end;
+
+			if (get_range_by_index (entry_text, n, &start, &end)) {
+				char *text;
+
+				text = get_entry_substring (name_selector_entry, start, end);
+				if (text) {
+					if (str->str && str->str[0])
+						g_string_append (str, ", ");
+
+					g_string_append (str, text);
+				}
+				g_free (text);
+			} else {
+				g_warning ("ENameSelectorEntry is out of sync with model!");
+			}
+		}
+	}
+	g_list_free (known);
+
+	for (l = del; l != NULL; l = l->next) {
+		e_destination_store_remove_destination_nth (name_selector_entry->destination_store, GPOINTER_TO_INT (l->data));
+	}
+	g_list_free (del);
+
+	gtk_entry_set_text (GTK_ENTRY (name_selector_entry), str->str);
+
+	g_string_free (str, TRUE);
+
+	g_signal_handlers_unblock_matched (name_selector_entry->destination_store, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
+	g_signal_handlers_unblock_matched (name_selector_entry, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, name_selector_entry);
+
+	generate_attribute_list (name_selector_entry);
+}
+
 static gboolean
 user_focus_in (ENameSelectorEntry *name_selector_entry, GdkEventFocus *event_focus)
 {
@@ -1478,6 +1531,10 @@ user_focus_out (ENameSelectorEntry *name
 
 	clear_completion_model (name_selector_entry);
 
+	if (!event_focus->in) {
+		sanitize_entry (name_selector_entry);
+	}
+
 	return FALSE;
 }
 
Index: libedataserverui/ChangeLog
===================================================================
--- libedataserverui/ChangeLog	(revision 9438)
+++ libedataserverui/ChangeLog	(working copy)
@@ -1,3 +1,11 @@
+2008-08-27  Milan Crha  <mcrha@redhat.com>
+
+	** Fix for bug #326692
+
+	* e-name-selector-entry.c: (sanitize_entry), (user_focus_out):
+	Sync model data with entry text and remove all empty
+	destinations from the model on user's exit from the entry.
+
 2008-08-17  Matthew Barnes  <mbarnes@redhat.com>
 
 	** Fixes bug #547952
