summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Wimpress <[email protected]>2015-06-09 23:02:49 +0100
committerMartin Wimpress <[email protected]>2015-06-09 23:02:49 +0100
commitb8b9ba8d30ba5fc1b3843827ac48e9c503a213cc (patch)
treeb799384cfa67f00919f0fcd5a70547e360c67404 /src
parentb13fdb1bc25e62d20d068bf9293880d64cb899a5 (diff)
parent2c4fdb15e42f8327a677a637b1ce8b69583a7dc1 (diff)
downloadmate-power-manager-b8b9ba8d30ba5fc1b3843827ac48e9c503a213cc.tar.bz2
mate-power-manager-b8b9ba8d30ba5fc1b3843827ac48e9c503a213cc.tar.xz
Merge pull request #143 from pudh4418/fix-dbus-memleak
Fix memory leak problem when calling logind DBus method
Diffstat (limited to 'src')
-rw-r--r--src/gpm-control.c48
1 files changed, 27 insertions, 21 deletions
diff --git a/src/gpm-control.c b/src/gpm-control.c
index 0562d38..4091e0c 100644
--- a/src/gpm-control.c
+++ b/src/gpm-control.c
@@ -97,6 +97,7 @@ static gboolean
gpm_control_systemd_shutdown (void) {
GError *error = NULL;
GDBusProxy *proxy;
+ GVariant *res = NULL;
egg_debug ("Requesting systemd to shutdown");
proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
@@ -114,19 +115,20 @@ gpm_control_systemd_shutdown (void) {
return FALSE;
}
- g_dbus_proxy_call_sync (proxy, "PowerOff",
- g_variant_new( "(b)", FALSE),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &error
- );
+ res = g_dbus_proxy_call_sync (proxy, "PowerOff",
+ g_variant_new( "(b)", FALSE),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &error
+ );
if (error != NULL) {
egg_error ("Error in dbus - %s", error->message);
g_error_free (error);
return FALSE;
}
+ g_variant_unref(res);
return TRUE;
}
@@ -219,6 +221,7 @@ gpm_control_suspend (GpmControl *control, GError **error)
GError *dbus_error = NULL;
GDBusProxy *proxy;
+ GVariant *res = NULL;
screensaver = gpm_screensaver_new ();
@@ -272,19 +275,20 @@ gpm_control_suspend (GpmControl *control, GError **error)
g_error_free (dbus_error);
return -1;
}
- g_dbus_proxy_call_sync (proxy, "Suspend",
- g_variant_new( "(b)",FALSE),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &dbus_error
- );
+ res = g_dbus_proxy_call_sync (proxy, "Suspend",
+ g_variant_new( "(b)",FALSE),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &dbus_error
+ );
if (dbus_error != NULL ) {
egg_debug ("Error in dbus - %s", dbus_error->message);
g_error_free (dbus_error);
ret = TRUE;
}
else {
+ g_variant_unref(res);
ret = TRUE;
}
g_object_unref(proxy);
@@ -331,6 +335,7 @@ gpm_control_hibernate (GpmControl *control, GError **error)
GError *dbus_error = NULL;
GDBusProxy *proxy;
+ GVariant *res = NULL;
screensaver = gpm_screensaver_new ();
@@ -384,19 +389,20 @@ gpm_control_hibernate (GpmControl *control, GError **error)
g_error_free (dbus_error);
return -1;
}
- g_dbus_proxy_call_sync (proxy, "Hibernate",
- g_variant_new( "(b)",FALSE),
- G_DBUS_CALL_FLAGS_NONE,
- -1,
- NULL,
- &dbus_error
- );
+ res = g_dbus_proxy_call_sync (proxy, "Hibernate",
+ g_variant_new( "(b)",FALSE),
+ G_DBUS_CALL_FLAGS_NONE,
+ -1,
+ NULL,
+ &dbus_error
+ );
if (dbus_error != NULL ) {
egg_debug ("Error in dbus - %s", dbus_error->message);
g_error_free (dbus_error);
ret = TRUE;
}
else {
+ g_variant_unref(res);
ret = TRUE;
}
}