[gnome-software] packagekit: Don't refine packages after we've been cancelled



commit 3e1d1ac8e4cd4ad0a89cecb02f1125e62090ed5d
Author: Iain Lane <iain orangesquash org uk>
Date:   Wed Aug 30 11:51:30 2017 +0100

    packagekit: Don't refine packages after we've been cancelled
    
    gs_plugin_packagekit_resolve_packages_app marks packages as UNAVAILABLE
    if we haven't managed to map the package to its source. That works well
    in normal circumstances, but there is one time when it breaks.
    
    When searching, we will start a search operation once the user has typed
    enough characters. They may then continue to type more after we have
    begun the search and are in a PackageKit query. In that case, we will
    cancel the old search and the PK query will return no results. Then we
    hit the above case and the user is shown an UNAVAILABLE app.
    
    Instead, if we see we've been cancelled, do nothing and let the later
    search perform the resolution.
    
    https://bugs.launchpad.net/ubuntu/+source/gnome-software/+bug/1709657

 plugins/packagekit/gs-plugin-packagekit-refine.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/plugins/packagekit/gs-plugin-packagekit-refine.c 
b/plugins/packagekit/gs-plugin-packagekit-refine.c
index a699303..1de1d1e 100644
--- a/plugins/packagekit/gs-plugin-packagekit-refine.c
+++ b/plugins/packagekit/gs-plugin-packagekit-refine.c
@@ -282,6 +282,14 @@ gs_plugin_packagekit_resolve_packages (GsPlugin *plugin,
 
        /* get results */
        packages = pk_results_get_package_array (results);
+
+       /* if the user types more characters we'll get cancelled - don't go on
+        * to mark apps as unavailable because packages->len = 0 */
+       if (g_cancellable_is_cancelled (cancellable)) {
+               g_prefix_error (error, "not refining - cancelled: ");
+               return FALSE;
+       }
+
        for (i = 0; i < gs_app_list_length (list); i++) {
                app = gs_app_list_index (list, i);
                if (gs_app_get_local_file (app) != NULL)


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