Compare commits

...

1 commit

Author SHA1 Message Date
Nicolas Fella
f39a03fe13 [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
2020-12-07 19:50:04 +00:00

View file

@ -49,6 +49,13 @@ Notification::Notification(const NetworkPacket& np, const Device* device, QObjec
if(!m_requestReplyId.isEmpty() && actionIndex == 1) { if(!m_requestReplyId.isEmpty() && actionIndex == 1) {
return; 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 // Notification action indices start at 1
Q_EMIT actionTriggered(m_internalId, m_actions[actionIndex - 1]); Q_EMIT actionTriggered(m_internalId, m_actions[actionIndex - 1]);
}); });