[gnome-software/1529-in-search-the-first-app-opened-is-subsequently-opened-in-place-of-other-apps] gs-details-page: Cancel ongoing app details load when switching app
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc: 
- Subject: [gnome-software/1529-in-search-the-first-app-opened-is-subsequently-opened-in-place-of-other-apps] gs-details-page: Cancel ongoing app details load when switching app
- Date: Tue, 15 Mar 2022 07:13:31 +0000 (UTC)
commit 641e3ce6be03f49de5f18d7c48fc72486f676ce2
Author: Milan Crha <mcrha redhat com>
Date:   Tue Mar 15 08:10:45 2022 +0100
    gs-details-page: Cancel ongoing app details load when switching app
    
    Cancel any ongoing app details load when switching to a different app,
    thus any slow responses won't overwrite page content. That could happen
    when the lookup for app alternatives took too long. Once finished, it
    could change the selected app from the returned list, which was not
    relevant to the currently selected app.
    
    Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1529
 src/gs-details-page.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 2fef6e4f7..591b483e5 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -1691,12 +1691,16 @@ static void
 gs_details_page_load_stage1 (GsDetailsPage *self)
 {
        g_autoptr(GsPluginJob) plugin_job = NULL;
+       g_autoptr(GCancellable) cancellable = g_cancellable_new ();
 
        /* update UI */
        gs_page_switch_to (GS_PAGE (self));
        gs_page_scroll_up (GS_PAGE (self));
        gs_details_page_set_state (self, GS_DETAILS_PAGE_STATE_LOADING);
 
+       g_cancellable_cancel (self->cancellable);
+       g_set_object (&self->cancellable, cancellable);
+
        /* get extra details about the app */
        plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFINE,
                                         "app", self->app,
@@ -2096,7 +2100,7 @@ gs_details_page_setup (GsPage *page,
        self->shell = shell;
 
        self->plugin_loader = g_object_ref (plugin_loader);
-       self->cancellable = g_object_ref (cancellable);
+       self->cancellable = g_cancellable_new ();
 
        /* hide some UI when offline */
        g_signal_connect_object (self->plugin_loader, "notify::network-available",
[
Date Prev][
Date Next]   [
Thread Prev][
Thread Next]   
[
Thread Index]
[
Date Index]
[
Author Index]