Skip to content

Commit

Permalink
Fix race condition of ConversationModel::clear()
Browse files Browse the repository at this point in the history
When the ConversationModel is cleared after sending a message but before
the acknowledgement is received, Ricochet crashes.

issue blueprint-freespeech#150
  • Loading branch information
wfr committed May 2, 2022
1 parent b0a274c commit 0108abb
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/libtego_ui/shims/ConversationModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,13 @@ namespace shims

void ConversationModel::messageAcknowledged(tego_message_id_t messageId, bool accepted)
{
if (messages.size() == 0) {
// Reached when the model is cleared after an outgoing message was sent,
// but before it is acknowledged.
// https://github.com/blueprint-freespeech/ricochet-refresh/issues/150
return;
}

auto row = this->indexOfOutgoingMessage(messageId);
Q_ASSERT(row >= 0);

Expand Down

0 comments on commit 0108abb

Please sign in to comment.