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.
This commit is contained in:
@@ -381,10 +381,18 @@ void Controller::listenForNotifications()
|
|||||||
#ifdef HAVE_KUNIFIEDPUSH
|
#ifdef HAVE_KUNIFIEDPUSH
|
||||||
auto connector = new KUnifiedPush::Connector(QStringLiteral("org.kde.neochat"));
|
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);
|
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"));
|
connector->registerClient(i18n("Receiving push notifications"));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user