[gnome-control-center] info: Improve error handling for PackageKit version check
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] info: Improve error handling for PackageKit version check
- Date: Mon, 15 Apr 2013 15:19:12 +0000 (UTC)
commit 1c8609e2b342dab8a8e2d7f470a948c91abc09b2
Author: Kalev Lember <kalevlember gmail com>
Date: Fri Apr 12 22:57:18 2013 +0200
info: Improve error handling for PackageKit version check
Fixes critical errors when PackageKit isn't installed.
https://bugzilla.gnome.org/show_bug.cgi?id=697821
panels/info/cc-info-panel.c | 36 ++++++++++++++++++++++++++----------
1 file changed, 26 insertions(+), 10 deletions(-)
---
diff --git a/panels/info/cc-info-panel.c b/panels/info/cc-info-panel.c
index 453b8a6..1f79540 100644
--- a/panels/info/cc-info-panel.c
+++ b/panels/info/cc-info-panel.c
@@ -1738,13 +1738,28 @@ on_updates_button_clicked (GtkWidget *widget,
}
}
+static gboolean
+get_pk_version_property (GDBusProxy *pk_proxy,
+ const char *property,
+ guint32 *retval)
+{
+ GVariant *v;
+
+ v = g_dbus_proxy_get_cached_property (pk_proxy, property);
+ if (!v)
+ return FALSE;
+
+ g_variant_get (v, "u", retval);
+ g_variant_unref (v);
+ return TRUE;
+}
+
static void
got_pk_proxy_cb (GObject *source_object,
GAsyncResult *res,
CcInfoPanel *self)
{
GError *error = NULL;
- GVariant *v;
guint32 major, minor, micro;
self->priv->pk_proxy = g_dbus_proxy_new_for_bus_finish (res, &error);
@@ -1758,15 +1773,16 @@ got_pk_proxy_cb (GObject *source_object,
return;
}
- v = g_dbus_proxy_get_cached_property (self->priv->pk_proxy, "VersionMajor");
- g_variant_get (v, "u", &major);
- g_variant_unref (v);
- v = g_dbus_proxy_get_cached_property (self->priv->pk_proxy, "VersionMinor");
- g_variant_get (v, "u", &minor);
- g_variant_unref (v);
- v = g_dbus_proxy_get_cached_property (self->priv->pk_proxy, "VersionMicro");
- g_variant_get (v, "u", µ);
- g_variant_unref (v);
+ if (!get_pk_version_property(self->priv->pk_proxy, "VersionMajor", &major) ||
+ !get_pk_version_property(self->priv->pk_proxy, "VersionMinor", &minor) ||
+ !get_pk_version_property(self->priv->pk_proxy, "VersionMicro", µ))
+ {
+ g_warning ("Unable to get PackageKit version");
+ g_clear_object (&self->priv->pk_proxy);
+ self->priv->updates_state = PK_NOT_AVAILABLE;
+ refresh_update_button (self);
+ return;
+ }
if (major != 0 || minor != 8)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]