[gnome-applets] battstat: fix memory leak
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-applets] battstat: fix memory leak
- Date: Sat, 29 Feb 2020 12:50:05 +0000 (UTC)
commit 3f6de9a77fd8284f2c720244e867a8604ed83611
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Sat Feb 29 14:35:16 2020 +0200
battstat: fix memory leak
up_client_get_devices did not set free function on GPtrArray meaning
that g_ptr_array_unref was not enough to free devices.
battstat/src/battstat-upower.c | 15 ++-------------
configure.ac | 2 +-
2 files changed, 3 insertions(+), 14 deletions(-)
---
diff --git a/battstat/src/battstat-upower.c b/battstat/src/battstat-upower.c
index fad128e7a..c645b065f 100644
--- a/battstat/src/battstat-upower.c
+++ b/battstat/src/battstat-upower.c
@@ -85,25 +85,14 @@ battstat_upower_initialise (void (*callback) (void))
if( (upc = up_client_new() ) == NULL )
goto error_out;
-#if UP_CHECK_VERSION(0, 99, 0)
- devices = up_client_get_devices(upc);
+ devices = up_client_get_devices2(upc);
if (!devices) {
goto error_shutdownclient;
}
g_ptr_array_unref(devices);
-#else
- if (! up_client_enumerate_devices_sync( upc, NULL, NULL ) ) {
- goto error_shutdownclient;
- }
-#endif
g_signal_connect_after( upc, "device-added", device_cb, NULL );
-#if UP_CHECK_VERSION(0, 99, 0)
g_signal_connect_after( upc, "device-removed", device_removed_cb, NULL );
-#else
- g_signal_connect_after( upc, "device-changed", device_cb, NULL );
- g_signal_connect_after( upc, "device-removed", device_cb, NULL );
-#endif
return NULL;
@@ -143,7 +132,7 @@ void
battstat_upower_get_battery_info( BatteryStatus *status )
{
- GPtrArray *devices = up_client_get_devices( upc );
+ GPtrArray *devices = up_client_get_devices2( upc );
/* The calculation to get overall percentage power remaining is as follows:
*
diff --git a/configure.ac b/configure.ac
index ab1a3877c..b24226101 100644
--- a/configure.ac
+++ b/configure.ac
@@ -66,7 +66,7 @@ LIBPANEL_REQUIRED=3.24.1
LIBGTOP_REQUIRED=2.11.92
LIBWNCK_REQUIRED=3.14.1
LIBNOTIFY_REQUIRED=0.7
-UPOWER_REQUIRED=0.9.4
+UPOWER_REQUIRED=0.99.8
DBUS_REQUIRED=1.1.2
DBUS_GLIB_REQUIRED=0.74
ADWAITA_ICON_THEME_REQUIRED=3.14.0
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]