From fc2fd48b965bd004fda0d7746d2b1c966763bd4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole-Andr=C3=A9=20Rodlie?= Date: Tue, 23 Jan 2024 22:34:25 +0100 Subject: [PATCH] Update powerkit.cpp - Avoid potential crash when calling register suspend lock - Fix broken register suspend lock call on logind Yes, the project is still alive. --- src/powerkit.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/powerkit.cpp b/src/powerkit.cpp index 9c3d88e..d6e417e 100644 --- a/src/powerkit.cpp +++ b/src/powerkit.cpp @@ -488,13 +488,13 @@ bool PowerKit::registerSuspendLock() if (suspendLock) { return false; } qDebug() << "register suspend lock"; QDBusReply reply; - if (HasLogind() && logind->isValid()) { - reply = ckit->call("Inhibit", - "sleep", - "powerkit", - "Lock screen etc", - "delay"); - } else if (HasConsoleKit() && ckit->isValid()) { + if (HasLogind() && logind && logind->isValid()) { + reply = logind->call("Inhibit", + "sleep", + "powerkit", + "Lock screen etc", + "delay"); + } else if (HasConsoleKit() && ckit && ckit->isValid()) { reply = ckit->call("Inhibit", "sleep", "powerkit",