summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2019-09-24 19:49:05 +0200
committerraveit65 <[email protected]>2019-09-26 11:08:59 +0200
commit9d5b257f74d396ad4ed3d144185ab95b318b03b8 (patch)
tree3f0a85eed9fc9651892f016f98b73f006ad94330
parent718962729f58c7acbc2b5b3427c2de8909669eee (diff)
downloadmate-power-manager-9d5b257f74d396ad4ed3d144185ab95b318b03b8.tar.bz2
mate-power-manager-9d5b257f74d396ad4ed3d144185ab95b318b03b8.tar.xz
Use up_client_get_devices2()
The previous code would have leaked all the UpDevice objects because no free function was set on the returned GPtrArray. With depending on upower-glib 0.99.8 get_devices() was deprecated and get_devices2() was introduced, we can simply switch to get_devices2() which does set a free function on the returned GPtrArray, stopping the leak. Inspired from: https://gitlab.gnome.org/GNOME/gnome-control-center/commit/c1210c5 see upower upstream: https://gitlab.freedesktop.org/upower/upower/commit/cb1071b
-rw-r--r--src/gpm-engine.c2
-rw-r--r--src/gpm-prefs-core.c2
-rw-r--r--src/gpm-statistics.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/src/gpm-engine.c b/src/gpm-engine.c
index 4ffce52..248553c 100644
--- a/src/gpm-engine.c
+++ b/src/gpm-engine.c
@@ -864,7 +864,7 @@ gpm_engine_coldplug_idle_cb (GpmEngine *engine)
gpm_engine_recalculate_state (engine);
/* add to database */
- array = up_client_get_devices (engine->priv->client);
+ array = up_client_get_devices2 (engine->priv->client);
for (i=0;i<array->len;i++) {
device = g_ptr_array_index (array, i);
gpm_engine_device_add (engine, device);
diff --git a/src/gpm-prefs-core.c b/src/gpm-prefs-core.c
index 2f07c14..a0dea5a 100644
--- a/src/gpm-prefs-core.c
+++ b/src/gpm-prefs-core.c
@@ -818,7 +818,7 @@ gpm_prefs_init (GpmPrefs *prefs)
g_error_free (error);
}
#endif
- devices = up_client_get_devices (prefs->priv->client);
+ devices = up_client_get_devices2 (prefs->priv->client);
for (i=0; i<devices->len; i++) {
device = g_ptr_array_index (devices, i);
g_object_get (device,
diff --git a/src/gpm-statistics.c b/src/gpm-statistics.c
index fc302a4..34541f6 100644
--- a/src/gpm-statistics.c
+++ b/src/gpm-statistics.c
@@ -1796,7 +1796,7 @@ main (int argc, char *argv[])
if (!ret)
goto out;
#endif
- devices = up_client_get_devices (client);
+ devices = up_client_get_devices2 (client);
/* add devices in visually pleasing order */
for (j=0; j<UP_DEVICE_KIND_LAST; j++) {