From 7795404514d329fa6fcd7bb5addb02fc49a73877 Mon Sep 17 00:00:00 2001 From: Michael Weiser Date: Wed, 8 Jan 2020 22:57:43 +0100 Subject: [PATCH] Fix inhibitor listing in xfce4-screensaver-command The command would not reflect inhibited status and would not show the inhibitors. This was due to the fact that unref'ing the reply gobject also invalidates the body extracted from it and the iterator was set up with the wrong format string. Also, the body is a container and always contains the inhibitor array element, even if it's empty. Therefore we have to check the number of children of the actual array variant and not the body. Change both to get inhibitors listed and inhibition status shown when querying status. --- src/xfce4-screensaver-command.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/xfce4-screensaver-command.c b/src/xfce4-screensaver-command.c index 98daefb..585e86a 100644 --- a/src/xfce4-screensaver-command.c +++ b/src/xfce4-screensaver-command.c @@ -211,18 +211,18 @@ do_command (GDBusConnection *conn) { goto done; } body = g_dbus_message_get_body (reply); - g_object_unref (reply); + g_variant_get (body, "(as)", &iter); - if (g_variant_n_children(body) <= 0) { + if (g_variant_iter_n_children(iter) <= 0) { g_print (_("The screensaver is not inhibited\n")); } else { - g_variant_get (body, "s", &iter); g_print (_("The screensaver is being inhibited by:\n")); while (g_variant_iter_loop (iter, "s", &str)) { g_print ("\t%s\n", str); } - g_variant_iter_free (iter); } + g_variant_iter_free (iter); + g_object_unref (reply); } if (do_time) { -- 2.24.1