Commit 76bcb55f authored by Claudio Cambra's avatar Claudio Cambra Committed by Carl Schwan
Browse files

Prevent crashing from null AlarmNotification pointer

Backport of !29
parent 26694e8c
Pipeline #197947 passed with stage
in 1 minute and 51 seconds
......@@ -259,16 +259,32 @@ void KalendarAlarmClient::checkAlarms()
}
}
QVector<QString> nullAlarmNotificationIds;
// execute or update active alarms
for (auto it = m_notifications.begin(); it != m_notifications.end(); ++it) {
if (it.value()->remindAt() <= mLastChecked) {
const auto incidence = mCalendar->incidence(it.value()->uid());
const auto notification = it.value();
// Protect against null ptr
if(!notification) {
qCDebug(Log) << "Found null active alarm with id: " << it.key() << "Skipping.";
nullAlarmNotificationIds.append(it.key());
continue;
}
if (notification->remindAt() <= mLastChecked) {
const auto incidence = mCalendar->incidence(notification->uid());
if (incidence) { // can still be null when we get here during the early stages of loading/restoring
it.value()->send(this, incidence);
notification->send(this, incidence);
}
}
}
// Remove the null alarm notification ptrs from our notifications
for(const auto &nullAlarmId : nullAlarmNotificationIds) {
m_notifications.remove(nullAlarmId);
}
saveLastCheckTime();
// schedule next check for the beginning of the next minute
......
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