[PATCH] daemon: Update aggregate device on battery removal

Evangelos Foutras evangelos at foutrelis.com
Thu Oct 2 06:16:34 PDT 2014


https://bugs.freedesktop.org/show_bug.cgi?id=84345
---
I'm not sure if this is the correct way to fix this but it works for me.

 src/up-daemon.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/up-daemon.c b/src/up-daemon.c
index a0a932c..e676e3b 100644
--- a/src/up-daemon.c
+++ b/src/up-daemon.c
@@ -1035,6 +1035,7 @@ up_daemon_device_removed_cb (UpBackend *backend, GObject *native, UpDevice *devi
 {
 	const gchar *object_path;
 	UpDaemonPrivate *priv = daemon->priv;
+	UpDeviceLevel warning_level;
 
 	g_return_if_fail (UP_IS_DAEMON (daemon));
 	g_return_if_fail (UP_IS_DEVICE (device));
@@ -1043,6 +1044,12 @@ up_daemon_device_removed_cb (UpBackend *backend, GObject *native, UpDevice *devi
 	/* remove from list */
 	up_device_list_remove (priv->power_devices, G_OBJECT(device));
 
+	/* update our internal state in case a battery was removed; this also
+	   ensures that the display device contains up to date information */
+	warning_level = up_daemon_get_warning_level_local (daemon);
+	if (warning_level != priv->warning_level)
+		up_daemon_set_warning_level (daemon, warning_level);
+
 	/* emit */
 	object_path = up_device_get_object_path (device);
 	g_debug ("emitting device-removed: %s", object_path);
-- 
2.1.2



More information about the devkit-devel mailing list