Check if RoomEvent is null before trying to insert a notification
As seen in the bug report, roomEvent could be null and then we get a nice and simple null-access error. We should be careful before trying to use it. BUG: 502687
This commit is contained in:
@@ -121,6 +121,10 @@ void NotificationsModel::loadData()
|
|||||||
const auto &authorAvatar = avatar.isValid() && avatar.scheme() == u"mxc"_s ? avatar : QUrl();
|
const auto &authorAvatar = avatar.isValid() && avatar.scheme() == u"mxc"_s ? avatar : QUrl();
|
||||||
|
|
||||||
const auto &roomEvent = eventCast<const RoomEvent>(notification.event.get());
|
const auto &roomEvent = eventCast<const RoomEvent>(notification.event.get());
|
||||||
|
if (!roomEvent) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
beginInsertRows({}, m_notifications.length(), m_notifications.length());
|
beginInsertRows({}, m_notifications.length(), m_notifications.length());
|
||||||
m_notifications += Notification{
|
m_notifications += Notification{
|
||||||
.roomId = notification.roomId,
|
.roomId = notification.roomId,
|
||||||
|
|||||||
Reference in New Issue
Block a user