From 3caa5ad2edc3001050917403beec100993337e79 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sat, 16 Dec 2023 20:41:47 -0500 Subject: [PATCH] Prevent KUnifiedPush-activated daemon from sticking around forever Erroneous activations of the D-Bus service could cause the daemon to be launched without any messageReceived signals being called (which then hooks up the notifications to quit the app.) Now there's a five-second timeout to prevent it from living too long. --- src/controller.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/controller.cpp b/src/controller.cpp index 4e031c941..b2449bfda 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -381,10 +381,18 @@ void Controller::listenForNotifications() #ifdef HAVE_KUNIFIEDPUSH auto connector = new KUnifiedPush::Connector(QStringLiteral("org.kde.neochat")); - connect(connector, &KUnifiedPush::Connector::messageReceived, [](const QByteArray &data) { + auto timer = new QTimer(); + connect(timer, &QTimer::timeout, qGuiApp, &QGuiApplication::quit); + + connect(connector, &KUnifiedPush::Connector::messageReceived, [timer](const QByteArray &data) { NotificationsManager::instance().postPushNotification(data); + timer->stop(); }); + // Wait five seconds to see if we received any messages or this happened to be an erroneous activation. + // Otherwise, messageReceived is never activated, and this daemon could stick around forever. + timer->start(5000); + connector->registerClient(i18n("Receiving push notifications")); #endif }