From a1513b30cd3b7cf4d01d99facae9c8de9cccea97 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 14 May 2025 18:54:28 -0400 Subject: [PATCH] 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 --- src/app/models/notificationsmodel.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/app/models/notificationsmodel.cpp b/src/app/models/notificationsmodel.cpp index d47fc9ed5..342ae786b 100644 --- a/src/app/models/notificationsmodel.cpp +++ b/src/app/models/notificationsmodel.cpp @@ -121,6 +121,10 @@ void NotificationsModel::loadData() const auto &authorAvatar = avatar.isValid() && avatar.scheme() == u"mxc"_s ? avatar : QUrl(); const auto &roomEvent = eventCast(notification.event.get()); + if (!roomEvent) { + continue; + } + beginInsertRows({}, m_notifications.length(), m_notifications.length()); m_notifications += Notification{ .roomId = notification.roomId,