[gnome-software] Make search cancelling quicker



commit ed48662f293947ab7d206d7bd59abc9c64bb4ad1
Author: Kalev Lember <kalevlember gmail com>
Date:   Sun Oct 5 16:36:29 2014 +0200

    Make search cancelling quicker
    
    Sprinkle g_cancellable_set_error_if_cancelled() checks in search loops
    to exit earlier if the search gets cancelled.
    
    This should make find-as-you-type search more responsive.

 src/plugins/gs-plugin-appstream.c |    9 ++++++++-
 src/plugins/gs-plugin-epiphany.c  |    3 +++
 2 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/src/plugins/gs-plugin-appstream.c b/src/plugins/gs-plugin-appstream.c
index bc37efb..71ad8ea 100644
--- a/src/plugins/gs-plugin-appstream.c
+++ b/src/plugins/gs-plugin-appstream.c
@@ -944,6 +944,7 @@ gs_plugin_add_search_item (GsPlugin *plugin,
                           GList **list,
                           AsApp *app,
                           gchar **values,
+                          GCancellable *cancellable,
                           GError **error)
 {
        AsApp *item;
@@ -971,6 +972,9 @@ gs_plugin_add_search_item (GsPlugin *plugin,
 
        /* add the thing that we extend, not the addon itself */
        for (i = 0; i < extends->len; i++) {
+               if (g_cancellable_set_error_if_cancelled (cancellable, error))
+                       goto out;
+
                id = g_ptr_array_index (extends, i);
                item = as_store_get_app_by_id (plugin->priv->store, id);
                if (item == NULL)
@@ -1014,8 +1018,11 @@ gs_plugin_add_search (GsPlugin *plugin,
        gs_profile_start (plugin->profile, "appstream::search");
        array = as_store_get_apps (plugin->priv->store);
        for (i = 0; i < array->len; i++) {
+               if (g_cancellable_set_error_if_cancelled (cancellable, error))
+                       goto out;
+
                item = g_ptr_array_index (array, i);
-               ret = gs_plugin_add_search_item (plugin, list, item, values, error);
+               ret = gs_plugin_add_search_item (plugin, list, item, values, cancellable, error);
                if (!ret)
                        goto out;
        }
diff --git a/src/plugins/gs-plugin-epiphany.c b/src/plugins/gs-plugin-epiphany.c
index 353cfda..31f7295 100644
--- a/src/plugins/gs-plugin-epiphany.c
+++ b/src/plugins/gs-plugin-epiphany.c
@@ -297,6 +297,9 @@ gs_plugin_add_search (GsPlugin *plugin,
 
        /* add any matching apps */
        for (l = plugin->priv->list; l != NULL; l = l->next) {
+               if (g_cancellable_set_error_if_cancelled (cancellable, error))
+                       goto out;
+
                app = GS_APP (l->data);
                if (gs_plugin_epiphany_match_app (app, values))
                        gs_plugin_add_app (list, app);


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