[plugins/notifications] Prevent crash when default notification action is invoked.

When the notification's default action is activated, i.e. the notification is clicked, activated with index 0 is emitted.
This will lead to a crash since m_actions[-1] will be accessed.

This does not happen on Plasma since we don't specify that we have a default action and thus the notification isn't clickable.
However on LXDE the notification is clickable regardless and we get the according signal.

This arguably works around a bug in LXDE, but given that the workaround is cheap and other systems may behave this way too I think it's reasonable to do this.

BUG: 427717
This commit is contained in:
Nicolas Fella 2020-10-15 17:45:13 +02:00
parent 38afb807bf
commit f39a03fe13

View file

@ -49,6 +49,13 @@ Notification::Notification(const NetworkPacket& np, const Device* device, QObjec
if(!m_requestReplyId.isEmpty() && actionIndex == 1) {
return;
}
// index 0 is the default action. Some notification servers send this even though they shouldn't.
// https://bugs.kde.org/show_bug.cgi?id=427717
if (actionIndex == 0) {
return;
}
// Notification action indices start at 1
Q_EMIT actionTriggered(m_internalId, m_actions[actionIndex - 1]);
});