summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2018-03-02 17:39:23 +0100
committerBastien Nocera <hadess@hadess.net>2018-03-02 17:47:14 +0100
commit41bce284476030b22cd6d60280fb875f507f47a2 (patch)
treeba4621b1efd652726b62679db5a18c025679ea9f
parentcc37137637a7bf1e1b48ec328ae13e47b63aaa88 (diff)
downloadupower-41bce284476030b22cd6d60280fb875f507f47a2.tar.gz
lib: Fix warnings when D-Bus related properties change
When UPower would appear, or disappear, we'd get warnings like: g_object_notify: object class 'UpDevice' has no property named 'g-name-owner' or: g_object_notify: object class 'UpClient' has no property named 'g-name-owner' This was caused by the property proxying added in 7531dbd and 28438a7 being too lax about which properties it tried to proxy, which included ones that didn't apply to the object types in question. See https://bugs.freedesktop.org/show_bug.cgi?id=43001 https://bugs.freedesktop.org/show_bug.cgi?id=102350
-rw-r--r--libupower-glib/up-client.c7
-rw-r--r--libupower-glib/up-device.c7
2 files changed, 13 insertions, 1 deletions
diff --git a/libupower-glib/up-client.c b/libupower-glib/up-client.c
index 330c0ad..d92a407 100644
--- a/libupower-glib/up-client.c
+++ b/libupower-glib/up-client.c
@@ -274,7 +274,12 @@ up_client_notify_cb (GObject *gobject,
UpClient *client)
{
/* Proxy the notification from the D-Bus glue object
- * to the real one */
+ * to the real one, but only if the property exists
+ * for UpClient */
+ if (!g_object_class_find_property (G_OBJECT_GET_CLASS (client),
+ pspec->name))
+ return;
+
g_object_notify (G_OBJECT (client), pspec->name);
}
diff --git a/libupower-glib/up-device.c b/libupower-glib/up-device.c
index 4015039..f90b862 100644
--- a/libupower-glib/up-device.c
+++ b/libupower-glib/up-device.c
@@ -103,6 +103,13 @@ G_DEFINE_TYPE (UpDevice, up_device, G_TYPE_OBJECT)
static void
up_device_changed_cb (UpExportedDevice *proxy, GParamSpec *pspec, UpDevice *device)
{
+ /* Proxy the notification from the D-Bus glue object
+ * to the real one, but only if the property exists
+ * for UpClient */
+ if (!g_object_class_find_property (G_OBJECT_GET_CLASS (device), pspec->name) &&
+ !g_str_equal (pspec->name, "type"))
+ return;
+
if (g_strcmp0 (pspec->name, "type") == 0)
g_object_notify (G_OBJECT (device), "kind");
else