Re: [evolution-patches] 33708 LDAP+local autocompletion



I made a couple of modifications (entire revised patch is included
here).

     1. in e_select_names_completion_got_book_view_cb: move the
        initialization of book_data and comp to above their new use.
     2. in e_select_names_completion_start_query: don't increment
        pending_completion_seq if the get_book_view call failed.
     3. in e_select_names_completion_start_query: we don't need the
        "async" variable now, since pending_completion_seq serves that
        purpose.

Chris

On Fri, 2003-04-11 at 12:30, Dan Winship wrote:
> I *think* this fixes the bug (LDAP completions failing to show up
> sometimes if you also have another contacts folder enabled for
> autocompletion), although since it only happens sporadically, I'll want
> to run with the patch for a little while to make sure.
> 
> (The specific problem this fixes is a race condition where if the local
> contacts folder returns all of its results before the ldap completion
> folder even returns a bookview, then the ldap results are discarded.)
> 
> 
> ______________________________________________________________________
> Index: e-select-names-completion.c
> ===================================================================
> RCS file: /cvs/gnome/evolution/addressbook/gui/component/select-names/e-select-names-completion.c,v
> retrieving revision 1.61
> diff -u -r1.61 e-select-names-completion.c
> --- e-select-names-completion.c	9 Apr 2003 10:15:05 -0000	1.61
> +++ e-select-names-completion.c	11 Apr 2003 19:06:34 -0000
> @@ -731,13 +731,34 @@
>  }
>  
>  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)
> +	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 = (ESelectNamesCompletionBookData*)user_data;
>  	comp = book_data->comp;
> @@ -772,7 +793,6 @@
>  				  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 @@
>  			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
> @@ -975,6 +984,7 @@
>  											       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");
> +					comp->priv->pending_completion_seq++;
>  				}
>  
>  				if (out)
Index: e-select-names-completion.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/component/select-names/e-select-names-completion.c,v
retrieving revision 1.61
diff -u -r1.61 e-select-names-completion.c
--- e-select-names-completion.c	9 Apr 2003 10:15:05 -0000	1.61
+++ e-select-names-completion.c	14 Apr 2003 23:09:44 -0000
@@ -731,17 +731,38 @@
 }
 
 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 @@
 				  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 @@
 			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 @@
 		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 @@
 					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_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 @@
 			   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;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]