Set unsupported to true on error in FreeDesktopScreenSaver

This avoids possible memory leaks when the editor exits.
This commit is contained in:
风青山 2025-03-08 18:36:41 +08:00
parent b5bdb88062
commit 7fd154c4b4
No known key found for this signature in database
GPG key ID: 056264D70ECB0FD5

View file

@ -79,7 +79,7 @@ void FreeDesktopScreenSaver::inhibit() {
if (dbus_error_is_set(&error)) {
dbus_error_free(&error);
dbus_connection_unref(bus);
unsupported = false;
unsupported = true;
return;
}
@ -116,6 +116,7 @@ void FreeDesktopScreenSaver::uninhibit() {
DBUS_TYPE_INVALID);
DBusMessage *reply = dbus_connection_send_with_reply_and_block(bus, message, 50, &error);
dbus_message_unref(message);
if (dbus_error_is_set(&error)) {
dbus_error_free(&error);
dbus_connection_unref(bus);
@ -125,7 +126,6 @@ void FreeDesktopScreenSaver::uninhibit() {
print_verbose("FreeDesktopScreenSaver: Released screensaver inhibition cookie: " + uitos(cookie));
dbus_message_unref(message);
dbus_message_unref(reply);
dbus_connection_unref(bus);
}