From 1432b20cf2ce84373b11bd5ce87dbd8318aadf2b Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Fri, 3 Mar 2017 22:20:04 +0000 Subject: [PATCH 3/3] Do not reload the updates list when updates are in progress Resolves: https://bugzilla.gnome.org/show_bug.cgi?id=779463 --- src/gs-page.c | 9 +++++++++ src/gs-page.h | 1 + src/gs-shell-updates.c | 24 ++++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/src/gs-page.c b/src/gs-page.c index a5cf904..d6b0403 100644 --- a/src/gs-page.c +++ b/src/gs-page.c @@ -37,6 +37,7 @@ typedef struct GsShell *shell; GtkWidget *header_start_widget; GtkWidget *header_end_widget; + gboolean is_active; } GsPagePrivate; G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (GsPage, gs_page, GTK_TYPE_BIN) @@ -600,6 +601,14 @@ gs_page_shortcut_remove (GsPage *page, GsApp *app, GCancellable *cancellable) NULL); } +gboolean +gs_page_is_active (GsPage *page) +{ + GsPagePrivate *priv = gs_page_get_instance_private (page); + g_return_val_if_fail (GS_IS_PAGE (page), FALSE); + return priv->is_active; +} + /** * gs_page_switch_to: * diff --git a/src/gs-page.h b/src/gs-page.h index 62d224f..a9d9155 100644 --- a/src/gs-page.h +++ b/src/gs-page.h @@ -90,6 +90,7 @@ gboolean gs_page_setup (GsPage *page, GtkBuilder *builder, GCancellable *cancellable, GError **error); +gboolean gs_page_is_active (GsPage *page); G_END_DECLS diff --git a/src/gs-shell-updates.c b/src/gs-shell-updates.c index a245dc7..9ef41d6 100644 --- a/src/gs-shell-updates.c +++ b/src/gs-shell-updates.c @@ -1226,6 +1226,24 @@ gs_shell_updates_invalidate_downloaded_upgrade (GsShellUpdates *self) gs_app_get_id (app)); } +static gboolean +gs_shell_update_are_updates_in_progress (GsShellUpdates *self) +{ + GsUpdateList *update_list = GS_UPDATE_LIST (self->list_box_updates); + g_autoptr(GsAppList) list = gs_update_list_get_apps (update_list); + for (guint i = 0; i < gs_app_list_length (list); i++) { + GsApp *app = gs_app_list_index (list, i); + switch (gs_app_get_state (app)) { + case AS_APP_STATE_INSTALLING: + case AS_APP_STATE_REMOVING: + case AS_APP_STATE_PURCHASING: + return TRUE; + break; + } + } + return FALSE; +} + static void gs_shell_updates_changed_cb (GsPluginLoader *plugin_loader, GsShellUpdates *self) @@ -1234,6 +1252,12 @@ gs_shell_updates_changed_cb (GsPluginLoader *plugin_loader, * then make sure all new packages are downloaded */ gs_shell_updates_invalidate_downloaded_upgrade (self); + /* check to see if any apps in the app list are in a processing state */ + if (gs_shell_update_are_updates_in_progress (self)) { + g_debug ("ignoring updates-changed as updates in progress"); + return; + } + /* refresh updates list */ gs_shell_updates_reload (GS_PAGE (self)); } -- 2.9.3