Commit e74a923b authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Fix crash with reminder-daemon when reminder dismissed as notifications are being iterated over

These bugs:


feature crashing when iterating over the `QHash` containing the notifications about to be emitted. This is likely caused by the fact that the user is able to dismiss a reminder when it is emitted, and dismissal removes this notification from the `QHash`. This can happen as the `QHash` is being iterated over, and boom.

This MR creates a copy of the notifications hash to iterate over when emitting notifications, preventing the crash from happening
parent bbeb47e5
Pipeline #205036 passed with stage
in 3 minutes and 18 seconds
......@@ -253,16 +253,19 @@ void KalendarAlarmClient::checkAlarms()
QVector<QString> nullAlarmNotificationIds;
// We need a copy of the notifications hash as some may get dismissed as we iterate over them, causing a crash
// BUG: 455902
const auto notificationsCopy = m_notifications;
// execute or update active alarms
for (auto it = m_notifications.begin(); it != m_notifications.end(); ++it) {
for (auto it = notificationsCopy.constBegin(); it != notificationsCopy.constEnd(); ++it) {
const auto notification = it.value();
// Protect against null ptr
if(!notification) {
qCDebug(Log) << "Found null active alarm with id: " << it.key() << "Skipping.";
if (notification->remindAt() <= mLastChecked) {
......@@ -275,7 +278,7 @@ void KalendarAlarmClient::checkAlarms()
// Remove the null alarm notification ptrs from our notifications
for(const auto &nullAlarmId : nullAlarmNotificationIds) {
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment