From 21431c80c9d6a1d95a5adbaacb26350b1d4b0201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Blin?= <sebastien.blin@savoirfairelinux.com> Date: Tue, 28 Jun 2022 15:13:26 -0400 Subject: [PATCH] conversationmodel: avoid loading loop if no messages Also avoid any potential crash if for whatever reason no interactions is detected Change-Id: I7738e3f39cd626ef4fc64612f71d55e73d567fa2 --- src/libclient/conversationmodel.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libclient/conversationmodel.cpp b/src/libclient/conversationmodel.cpp index 96b48ce45..8b83de72d 100644 --- a/src/libclient/conversationmodel.cpp +++ b/src/libclient/conversationmodel.cpp @@ -2239,7 +2239,7 @@ ConversationModelPimpl::slotConversationLoaded(uint32_t requestId, return; } - auto allLoaded = false; + auto allLoaded = messages.size() == 0; try { auto& conversation = getConversationForUid(conversationId).get(); @@ -2304,11 +2304,13 @@ ConversationModelPimpl::slotConversationLoaded(uint32_t requestId, } if (conversation.lastMessageUid.isEmpty() && !conversation.allMessagesLoaded && messages.size() != 0) { - QString newLast = conversation.interactions->rbegin()->first; - if (newLast == oldLast && !newLast.isEmpty()) { // [[unlikely]] in c++20 - qCritical() << "Loading loop detected for " << conversationId << "(" << newLast - << ")"; - return; + if (conversation.interactions->size() > 0) { + QString newLast = conversation.interactions->rbegin()->first; + if (newLast == oldLast && !newLast.isEmpty()) { // [[unlikely]] in c++20 + qCritical() << "Loading loop detected for " << conversationId << "(" << newLast + << ")"; + return; + } } // In this case, we only have loaded merge commits. Load more messages -- GitLab