[gnome-software/wip/ubuntu-xenial] Bind progress and state between GsApps
- From: William Hua <williamhua src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/ubuntu-xenial] Bind progress and state between GsApps
- Date: Wed, 11 May 2016 21:52:27 +0000 (UTC)
commit 740861982a186d460007b85971fef66eaae84d38
Author: William Hua <william hua canonical com>
Date: Wed May 11 14:50:29 2016 -0700
Bind progress and state between GsApps
Fixes a bug where switching between search and details shells puts the
app in an inconsistent state. See
https://bugs.launchpad.net/ubuntu/+source/gnome-software/+bug/1572155
src/plugins/gs-plugin-apt.cc | 41 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 39 insertions(+), 2 deletions(-)
---
diff --git a/src/plugins/gs-plugin-apt.cc b/src/plugins/gs-plugin-apt.cc
index a0c547d..cb5a24f 100644
--- a/src/plugins/gs-plugin-apt.cc
+++ b/src/plugins/gs-plugin-apt.cc
@@ -84,6 +84,7 @@ struct GsPluginPrivate {
GHashTable *installed_files;
GList *installed_packages;
GList *updatable_packages;
+ GHashTable *pending_apps;
};
const gchar *
@@ -149,6 +150,11 @@ gs_plugin_initialize (GsPlugin *plugin)
g_free,
g_free);
+ plugin->priv->pending_apps = g_hash_table_new_full (g_str_hash,
+ g_str_equal,
+ g_free,
+ g_object_unref);
+
g_mutex_init (&plugin->priv->mutex);
pkgInitConfig (*_config);
@@ -164,6 +170,7 @@ gs_plugin_destroy (GsPlugin *plugin)
g_clear_pointer (&plugin->priv->installed_files, g_hash_table_unref);
g_clear_pointer (&plugin->priv->installed_packages, g_list_free);
g_clear_pointer (&plugin->priv->updatable_packages, g_list_free);
+ g_clear_pointer (&plugin->priv->pending_apps, g_hash_table_unref);
g_mutex_unlock (&plugin->priv->mutex);
g_mutex_clear (&plugin->priv->mutex);
}
@@ -580,6 +587,7 @@ gs_plugin_refine (GsPlugin *plugin,
g_autofree gchar *fn = NULL;
g_autofree gchar *origin = NULL;
gchar *package = NULL;
+ GsApp *pending_app = NULL;
tmp = gs_app_get_id (app);
if (gs_app_get_source_id_default (app) == NULL && tmp) {
@@ -606,6 +614,19 @@ gs_plugin_refine (GsPlugin *plugin,
}
}
+ if (tmp != NULL) {
+ pending_app = (GsApp *) g_hash_table_lookup (plugin->priv->pending_apps, tmp);
+
+ if (pending_app != NULL) {
+ g_object_bind_property (pending_app, "progress",
+ app, "progress",
+ (GBindingFlags) (G_BINDING_SYNC_CREATE));
+ g_object_bind_property (pending_app, "state",
+ app, "state",
+ (GBindingFlags) (G_BINDING_SYNC_CREATE));
+ }
+ }
+
if (gs_app_get_source_default (app) == NULL)
continue;
@@ -617,7 +638,7 @@ gs_plugin_refine (GsPlugin *plugin,
gs_app_set_origin (app, origin);
gs_app_set_origin_ui (app, info->origin);
- if (gs_app_get_state (app) == AS_APP_STATE_UNKNOWN) {
+ if (gs_app_get_state (app) == AS_APP_STATE_UNKNOWN && pending_app == NULL) {
if (info->installed_version != NULL) {
if (info->update_version != NULL) {
gs_app_set_state (app, AS_APP_STATE_UPDATABLE_LIVE);
@@ -794,6 +815,9 @@ aptd_transaction (GsPlugin *plugin,
g_autoptr(GMainLoop) loop = NULL;
guint property_signal, finished_signal;
TransactionData data;
+ GHashTable *pending_apps;
+ GsApp *a;
+ GList *l;
conn = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, error);
if (conn == NULL)
@@ -859,8 +883,21 @@ aptd_transaction (GsPlugin *plugin,
-1,
NULL,
error);
- if (result != NULL)
+ if (result != NULL) {
+ pending_apps = plugin->priv->pending_apps;
+
+ if (app)
+ g_hash_table_insert (pending_apps,
+ g_strdup (gs_app_get_id (app)),
+ g_object_ref (app));
+
+ for (l = apps; l != NULL; l = l->next)
+ g_hash_table_insert (pending_apps,
+ g_strdup (gs_app_get_id (GS_APP (l->data))),
+ g_object_ref (l->data));
+
g_main_loop_run (loop);
+ }
g_dbus_connection_signal_unsubscribe (conn, property_signal);
g_dbus_connection_signal_unsubscribe (conn, finished_signal);
if (result == NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]