From 3fa9162b67f4ef126264c38af659af610b01efd4 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Wed, 23 Apr 2003 20:32:02 +0000 Subject: [ either mostly or entirely fixes #33708 ] new function, factor it out of 2003-04-23 Chris Toshok [ either mostly or entirely fixes #33708 ] * gui/component/select-names/e-select-names-completion.c (e_select_names_completion_done): new function, factor it out of _seq_complete_cb because we need to run the same code in a couple of places. (e_select_names_completion_got_book_view_cb): treat an error from a book as getting a "sequence_complete", and decrement the count of pending complete signals. (e_select_names_completion_got_book_view_cb): remove the increment of pending_completion_seq from here. (e_select_names_completion_seq_complete_cb): factor out the body of e_select_names_completion_done from here, and call it. (e_select_names_completion_start_query): increment pending_completion_seq here. remove the async variable, as we can now use pending_completion_seq for that purpose (it's > 0 iff async would have been TRUE). svn path=/trunk/; revision=20943 --- .../select-names/e-select-names-completion.c | 49 +++++++++++++--------- 1 file changed, 29 insertions(+), 20 deletions(-) (limited to 'addressbook/gui') diff --git a/addressbook/gui/component/select-names/e-select-names-completion.c b/addressbook/gui/component/select-names/e-select-names-completion.c index 06e890f468..eb69f33afb 100644 --- a/addressbook/gui/component/select-names/e-select-names-completion.c +++ b/addressbook/gui/component/select-names/e-select-names-completion.c @@ -730,18 +730,39 @@ e_select_names_completion_clear_cache (ESelectNamesCompletionBookData *book_data book_data->cached_cards = NULL; } +static void +e_select_names_completion_done (ESelectNamesCompletion *comp) +{ + g_free (comp->priv->query_text); + comp->priv->query_text = NULL; + + e_completion_end_search (E_COMPLETION (comp)); /* That's all folks! */ + + /* Need to launch a new completion if another one is pending. */ + if (comp->priv->waiting_query) { + gchar *s = comp->priv->waiting_query; + comp->priv->waiting_query = NULL; + e_completion_begin_search (E_COMPLETION (comp), s, comp->priv->waiting_pos, comp->priv->waiting_limit); + g_free (s); + } +} + static void e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBookView *view, gpointer user_data) { ESelectNamesCompletion *comp; ESelectNamesCompletionBookData *book_data; - if (status != E_BOOK_STATUS_SUCCESS) - return; - book_data = (ESelectNamesCompletionBookData*)user_data; comp = book_data->comp; + if (status != E_BOOK_STATUS_SUCCESS) { + comp->priv->pending_completion_seq--; + if (!comp->priv->pending_completion_seq) + e_select_names_completion_done (comp); + return; + } + book_data->book_view_tag = 0; if (book_data->card_added_tag) { @@ -772,7 +793,6 @@ e_select_names_completion_got_book_view_cb (EBook *book, EBookStatus status, EBo G_CALLBACK (e_select_names_completion_seq_complete_cb), book_data); book_data->sequence_complete_received = FALSE; - comp->priv->pending_completion_seq++; } static void @@ -842,18 +862,7 @@ e_select_names_completion_seq_complete_cb (EBookView *book_view, EBookViewStatus return; } - g_free (comp->priv->query_text); - comp->priv->query_text = NULL; - - e_completion_end_search (E_COMPLETION (comp)); /* That's all folks! */ - - /* Need to launch a new completion if another one is pending. */ - if (comp->priv->waiting_query) { - gchar *s = comp->priv->waiting_query; - comp->priv->waiting_query = NULL; - e_completion_begin_search (E_COMPLETION (comp), s, comp->priv->waiting_pos, comp->priv->waiting_limit); - g_free (s); - } + e_select_names_completion_done (comp); } static void @@ -923,7 +932,6 @@ e_select_names_completion_start_query (ESelectNamesCompletion *comp, const gchar sexp = book_query_sexp (comp); if (sexp && *sexp) { GList *l; - gboolean async = FALSE; if (out) fprintf (out, "\n\n**** starting query: \"%s\"\n", comp->priv->query_text); @@ -966,7 +974,6 @@ e_select_names_completion_start_query (ESelectNamesCompletion *comp, const gchar book_query_process_card_list (comp, book_data->cached_cards); } else { - async = TRUE; e_select_names_completion_clear_cache (book_data); book_data->cached_query_text = g_strdup (query_text); @@ -975,6 +982,8 @@ e_select_names_completion_start_query (ESelectNamesCompletion *comp, const gchar e_select_names_completion_got_book_view_cb, book_data); if (! book_data->book_view_tag) g_warning ("Exception calling e_book_get_completion_view"); + else + comp->priv->pending_completion_seq++; } if (out) @@ -985,8 +994,8 @@ e_select_names_completion_start_query (ESelectNamesCompletion *comp, const gchar and were able to complete based solely on our cached cards, signal that the search is over. */ - if (!async) - e_completion_end_search (E_COMPLETION (comp)); + if (!comp->priv->pending_completion_seq) + e_select_names_completion_done (E_COMPLETION (comp)); } else { g_free (comp->priv->query_text); comp->priv->query_text = NULL; -- cgit v1.2.3