[gnome-software/1529-in-search-the-first-app-opened-is-subsequently-opened-in-place-of-other-apps-2] 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-2] gs-details-page: Cancel ongoing app details load when switching app
- Date: Tue, 15 Mar 2022 07:45:01 +0000 (UTC)
commit 72446752f9252c556f08ec09b3705cab1248419d
Author: Milan Crha <mcrha redhat com>
Date: Tue Mar 15 08:41:32 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 | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/src/gs-details-page.c b/src/gs-details-page.c
index 8db2a622e..dd1591087 100644
--- a/src/gs-details-page.c
+++ b/src/gs-details-page.c
@@ -1652,12 +1652,17 @@ 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);
+ g_cancellable_connect (self->cancellable, G_CALLBACK (gs_details_page_cancel_cb), self, NULL);
+
/* get extra details about the app */
plugin_job = gs_plugin_job_refine_new_for_app (self->app, GS_DETAILS_PAGE_REFINE_FLAGS);
gs_plugin_loader_job_process_async (self->plugin_loader, plugin_job,
@@ -2026,7 +2031,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 ();
g_cancellable_connect (cancellable, G_CALLBACK (gs_details_page_cancel_cb), self, NULL);
/* hide some UI when offline */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]