Skip to content

Commit 59ab0d5

Browse files
committed
Fix a crash on trying to mark unknown events as fully read
1 parent e16ed41 commit 59ab0d5

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

lib/room.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,10 @@ void Room::setReadReceipt(const QString& atEventId)
828828

829829
bool Room::Private::markMessagesAsRead(const rev_iter_t &upToMarker)
830830
{
831-
if (const auto changes = setFullyReadMarker(upToMarker->event()->id())) {
831+
if (upToMarker == q->historyEdge())
832+
qCWarning(MESSAGES) << "Cannot mark an unknown event in"
833+
<< q->objectName() << "as fully read";
834+
else if (const auto changes = setFullyReadMarker(upToMarker->event()->id())) {
832835
// The assumption below is that if a read receipt was sent on a newer
833836
// event, the homeserver will keep it there instead of reverting to
834837
// m.fully_read
@@ -837,15 +840,11 @@ bool Room::Private::markMessagesAsRead(const rev_iter_t &upToMarker)
837840
fullyReadUntilEventId);
838841
postprocessChanges(changes);
839842
return true;
840-
}
841-
if (upToMarker != q->historyEdge())
843+
} else
842844
qCDebug(MESSAGES) << "Event" << *upToMarker << "in" << q->objectName()
843845
<< "is behind the current fully read marker at"
844846
<< *q->fullyReadMarker()
845847
<< "- won't move fully read marker back in timeline";
846-
else
847-
qCWarning(MESSAGES) << "Cannot mark an unknown event in"
848-
<< q->objectName() << "as fully read";
849848
return false;
850849
}
851850

0 commit comments

Comments
 (0)