mirror of
https://github.com/swaywm/sway.git
synced 2024-11-17 13:42:36 +00:00
swayidle: when acquiring sleep lock, initialize and free variables properly
This commit is contained in:
parent
827e5513e0
commit
6e2dccc2e9
|
@ -81,16 +81,16 @@ static int release_lock(void *data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void acquire_sleep_lock(void) {
|
static void acquire_sleep_lock(void) {
|
||||||
sd_bus_message *msg;
|
sd_bus_message *msg = NULL;
|
||||||
sd_bus_error error;
|
sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||||
int ret = sd_bus_call_method(bus, "org.freedesktop.login1",
|
int ret = sd_bus_call_method(bus, "org.freedesktop.login1",
|
||||||
"/org/freedesktop/login1",
|
"/org/freedesktop/login1",
|
||||||
"org.freedesktop.login1.Manager", "Inhibit",
|
"org.freedesktop.login1.Manager", "Inhibit",
|
||||||
&error, &msg, "ssss", "sleep", "swayidle",
|
&error, &msg, "ssss", "sleep", "swayidle",
|
||||||
"Setup Up Lock Screen", "delay");
|
"Setup Up Lock Screen", "delay");
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wlr_log(WLR_ERROR, "Failed to send Inhibit signal: %s",
|
wlr_log(WLR_ERROR, "Failed to send Inhibit signal: %s", error.message);
|
||||||
strerror(-ret));
|
sd_bus_error_free(&error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,10 +98,11 @@ static void acquire_sleep_lock(void) {
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
wlr_log(WLR_ERROR, "Failed to parse D-Bus response for Inhibit: %s",
|
wlr_log(WLR_ERROR, "Failed to parse D-Bus response for Inhibit: %s",
|
||||||
strerror(-ret));
|
strerror(-ret));
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
wlr_log(WLR_INFO, "Got sleep lock: %d", lock_fd);
|
wlr_log(WLR_INFO, "Got sleep lock: %d", lock_fd);
|
||||||
|
}
|
||||||
|
sd_bus_error_free(&error);
|
||||||
|
sd_bus_message_unref(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int prepare_for_sleep(sd_bus_message *msg, void *userdata,
|
static int prepare_for_sleep(sd_bus_message *msg, void *userdata,
|
||||||
|
|
Loading…
Reference in a new issue