From 6ec48e33ef01476246d943d941eb2e022687ef59 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Tue, 30 Apr 2013 09:22:59 -0400 Subject: Make sure EAddressbookModel has a fresh EBookClient. In the event of an address book backend abort, EClientCache detects this and invalidates its cached EClient (if it has one), so a new instance is created on the next request. EAddressbookModel is only handed an EClient once, which may become stale if the backend aborts. And even if the backend is restarted the address book will remain unresponsive in Evolution. This commit changes the behavior so that every time an address book is selected in the side bar, a fresh EClient instance is obtained from the EClientCache and handed to the EAddressbookModel. If the model already has that EClient instance, nothing happens. Otherwise the model resets itself and creates a new EBookClientView. --- modules/addressbook/e-book-shell-view-private.c | 38 ++++++------------------- 1 file changed, 9 insertions(+), 29 deletions(-) diff --git a/modules/addressbook/e-book-shell-view-private.c b/modules/addressbook/e-book-shell-view-private.c index 8bb90fe758..70fb2c32b0 100644 --- a/modules/addressbook/e-book-shell-view-private.c +++ b/modules/addressbook/e-book-shell-view-private.c @@ -214,8 +214,8 @@ book_shell_view_client_connect_cb (GObject *source_object, EAddressbookModel *model; GError *error = NULL; - client = e_client_cache_get_client_finish ( - E_CLIENT_CACHE (source_object), result, &error); + client = e_client_selector_get_client_finish ( + E_CLIENT_SELECTOR (source_object), result, &error); /* Sanity check. */ g_return_if_fail ( @@ -256,13 +256,10 @@ static void book_shell_view_activate_selected_source (EBookShellView *book_shell_view, ESourceSelector *selector) { - EShell *shell; EShellView *shell_view; - EShellBackend *shell_backend; EBookShellContent *book_shell_content; EAddressbookView *view; EAddressbookModel *model; - EClientCache *client_cache; ESource *source; GalViewInstance *view_instance; GHashTable *hash_table; @@ -271,9 +268,6 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view, gchar *view_id; shell_view = E_SHELL_VIEW (book_shell_view); - shell_backend = e_shell_view_get_shell_backend (shell_view); - shell = e_shell_backend_get_shell (shell_backend); - client_cache = e_shell_get_client_cache (shell); book_shell_content = book_shell_view->priv->book_shell_content; source = e_source_selector_ref_primary_selection (selector); @@ -286,21 +280,8 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view, widget = g_hash_table_lookup (hash_table, uid); if (widget != NULL) { - /* There is a view for this UID. Make sure the view - * actually contains an EBook. The absence of an EBook - * suggests a previous load failed, so try again. */ view = E_ADDRESSBOOK_VIEW (widget); model = e_addressbook_view_get_model (view); - source = e_addressbook_view_get_source (view); - - if (e_addressbook_model_get_client (model) == NULL) - /* XXX No way to cancel this? */ - e_client_cache_get_client ( - client_cache, source, - E_SOURCE_EXTENSION_ADDRESS_BOOK, - NULL, - book_shell_view_client_connect_cb, - g_object_ref (view)); } else { /* Create a view for this UID. */ @@ -342,14 +323,6 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view, view = E_ADDRESSBOOK_VIEW (widget); model = e_addressbook_view_get_model (view); - /* XXX No way to cancel this? */ - e_client_cache_get_client ( - client_cache, source, - E_SOURCE_EXTENSION_ADDRESS_BOOK, - NULL, - book_shell_view_client_connect_cb, - g_object_ref (view)); - g_signal_connect_object ( model, "contact-changed", G_CALLBACK (contact_changed), @@ -366,6 +339,13 @@ book_shell_view_activate_selected_source (EBookShellView *book_shell_view, book_shell_view, G_CONNECT_SWAPPED); } + /* XXX No way to cancel this? */ + e_client_selector_get_client ( + E_CLIENT_SELECTOR (selector), + source, NULL, + book_shell_view_client_connect_cb, + g_object_ref (view)); + e_book_shell_content_set_current_view ( book_shell_content, E_ADDRESSBOOK_VIEW (widget)); -- cgit