[network/neochat] src/timeline/models: Fix crash when opening delegate context menu for images still loading

Joshua Goins <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit ffbaec6e724a4c3cc8aa83cca30e119cd39d62a8 by Joshua Goins.
Committed on 23/07/2026 at 22:12.
Pushed by redstrate into branch 'master'.

Fix crash when opening delegate context menu for images still loading

M  +10   -3    src/timeline/models/messagemodel.cpp

https://invent.kde.org/network/neochat/-/commit/ffbaec6e724a4c3cc8aa83cca30e119cd39d62a8

diff --git a/src/timeline/models/messagemodel.cpp b/src/timeline/models/messagemodel.cpp
index 77cee0fa1..0c766ad2a 100644
--- a/src/timeline/models/messagemodel.cpp
+++ b/src/timeline/models/messagemodel.cpp
@@ -796,17 +796,24 @@ void MessageModel::setHiddenFilter(std::function<bool(const Quotient::RoomEvent
 
 void MessageModel::hideMedia(const QString &eventId)
 {
-    ContentProvider::self().contentModelForEvent(roomForEvent(eventId), eventId)->hideMedia();
+    if (const auto contentModel = ContentProvider::self().contentModelForEvent(roomForEvent(eventId), eventId)) {
+        contentModel->hideMedia();
+    }
 }
 
 void MessageModel::showMedia(const QString &eventId)
 {
-    ContentProvider::self().contentModelForEvent(roomForEvent(eventId), eventId)->showMedia();
+    if (const auto contentModel = ContentProvider::self().contentModelForEvent(roomForEvent(eventId), eventId)) {
+        contentModel->showMedia();
+    }
 }
 
 bool MessageModel::isMediaHidden(const QString &eventId)
 {
-    return ContentProvider::self().contentModelForEvent(roomForEvent(eventId), eventId)->isMediaHidden();
+    if (const auto contentModel = ContentProvider::self().contentModelForEvent(roomForEvent(eventId), eventId)) {
+        return contentModel->isMediaHidden();
+    }
+    return false;
 }
 
 #include "moc_messagemodel.cpp"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.