[gnome-software] Don't cancel the search when pressing enter too quickly



commit ec5bf45e8be9bb65d7ceadc0a27b1d5b7deb9995
Author: Kalev Lember <kalevlember gmail com>
Date:   Thu May 29 23:33:07 2014 +0200

    Don't cancel the search when pressing enter too quickly
    
    Make sure to not cancel the pending search when another search with the
    same text comes in, e.g. when pressing enter quickly after having
    triggered the search-as-you-type search.
    
    This was caught thanks to gnome-continous and automated testing. Thanks!

 src/gs-shell-search.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)
---
diff --git a/src/gs-shell-search.c b/src/gs-shell-search.c
index a715da4..47e43e7 100644
--- a/src/gs-shell-search.c
+++ b/src/gs-shell-search.c
@@ -300,11 +300,6 @@ gs_shell_search_refresh (GsShellSearch *shell_search, const gchar *value, gboole
        widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "search_bar"));
        gtk_widget_show (widget);
 
-       if (priv->search_cancellable != NULL) {
-               g_cancellable_cancel (priv->search_cancellable);
-               g_clear_object (&priv->search_cancellable);
-       }
-
         if (scroll_up) {
                 GtkAdjustment *adj;
                 adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW 
(priv->scrolledwindow_search));
@@ -323,8 +318,9 @@ gs_shell_search_refresh (GsShellSearch *shell_search, const gchar *value, gboole
        /* remove old entries */
        gs_container_remove_all (GTK_CONTAINER (priv->list_box_search));
 
-       /* Initiate cancellable */
-       priv->search_cancellable = g_cancellable_new ();
+       /* cancel any pending searches */
+       g_cancellable_cancel (priv->search_cancellable);
+       g_cancellable_reset (priv->search_cancellable);
 
        /* search for apps */
        gs_plugin_loader_search_async (priv->plugin_loader,
@@ -529,6 +525,7 @@ gs_shell_search_init (GsShellSearch *shell_search)
        shell_search->priv = gs_shell_search_get_instance_private (shell_search);
        shell_search->priv->sizegroup_image = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
        shell_search->priv->sizegroup_name = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
+       shell_search->priv->search_cancellable = g_cancellable_new ();
 }
 
 /**


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