[Pkg-wmaker-commits] [wmbattery] 132/241: Fix upower detection.

Doug Torrance dtorrance-guest at moszumanska.debian.org
Mon Aug 24 23:37:47 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to branch master
in repository wmbattery.

commit 06dfd0d04639e5e4a316967393f2239ee05d74a0
Author: Andrew Shadura <andrew at shadura.me>
Date:   Fri Jul 18 01:07:52 2014 +0200

    Fix upower detection.
---
 upower.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/upower.c b/upower.c
index 03693a5..cb988e6 100644
--- a/upower.c
+++ b/upower.c
@@ -56,8 +56,16 @@ int upower_supported (void) {
 		return 0;
 	}
 	else {
-		g_object_unref(up);
-		return 1;
+		GPtrArray * devices = up_client_get_devices(up);
+
+		if (!devices) {
+			g_object_unref(up);
+			return 0;
+		} else {
+			g_ptr_array_unref(devices);
+			g_object_unref(up);
+			return 1;
+		}
 	}
 }
 
@@ -69,7 +77,7 @@ int upower_read(int battery, apm_info *info) {
 	up = up_client_new();
 
 	if (!up) {
-		return 0;
+		return -1;
 	}
 
 	#if !UP_CHECK_VERSION(0, 9, 99)
@@ -79,6 +87,10 @@ int upower_read(int battery, apm_info *info) {
 
 	devices = up_client_get_devices(up);
 
+	if (!devices) {
+		return -1;
+	}
+
 	info->battery_flags = 0;
 	info->using_minutes = 0;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbattery.git



More information about the Pkg-wmaker-commits mailing list