Fix crash in media url

This commit is contained in:
Tobias Fella
2023-05-07 09:40:11 +02:00
parent 8d45d4404e
commit a12a44b722

View File

@@ -1115,6 +1115,9 @@ QVariantMap MessageEventModel::getMediaInfoFromFileInfo(const EventContent::File
// Get the mxc URL for the media. // Get the mxc URL for the media.
#ifdef QUOTIENT_07 #ifdef QUOTIENT_07
if (!fileInfo->url().isValid() || eventId.isEmpty()) {
mediaInfo["source"] = QUrl();
} else {
QUrl source = m_currentRoom->makeMediaUrl(eventId, fileInfo->url()); QUrl source = m_currentRoom->makeMediaUrl(eventId, fileInfo->url());
if (source.isValid() && source.scheme() == QStringLiteral("mxc")) { if (source.isValid() && source.scheme() == QStringLiteral("mxc")) {
@@ -1122,6 +1125,7 @@ QVariantMap MessageEventModel::getMediaInfoFromFileInfo(const EventContent::File
} else { } else {
mediaInfo["source"] = QUrl(); mediaInfo["source"] = QUrl();
} }
}
#else #else
auto url = QUrl(m_currentRoom->connection()->homeserver().toString() + "/_matrix/media/r0/download/" + fileInfo->url.toString().remove("mxc://")); auto url = QUrl(m_currentRoom->connection()->homeserver().toString() + "/_matrix/media/r0/download/" + fileInfo->url.toString().remove("mxc://"));
QUrlQuery q(url.query()); QUrlQuery q(url.query());