Fix crash when adding recent messages to empty Channel (#3932)

* Fix crash when adding recent messages to empty Channel

* Update CHANGELOG.md
This commit is contained in:
Daniel Sage 2022-08-20 05:01:16 -04:00 committed by GitHub
parent c204332685
commit 33db006635
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View file

@ -26,7 +26,7 @@
- Minor: Removed total views from the usercard, as Twitch no longer updates the number. (#3792)
- Minor: Add Quick Switcher item to open a channel in a new popup window. (#3828)
- Minor: Warn when parsing an environment variable fails. (#3904)
- Minor: Load missing messages from Recent Messages API upon reconnecting (#3878)
- Minor: Load missing messages from Recent Messages API upon reconnecting (#3878, #3932)
- Bugfix: Fix crash that can occur when closing and quickly reopening a split, then running a command. (#3852)
- Bugfix: Connection to Twitch PubSub now recovers more reliably. (#3643, #3716)
- Bugfix: Fix crash that can occur when changing channels. (#3799)

View file

@ -237,7 +237,20 @@ void Channel::addMessagesAtStart(const std::vector<MessagePtr> &_messages)
void Channel::fillInMissingMessages(const std::vector<MessagePtr> &messages)
{
if (messages.empty())
{
return;
}
auto snapshot = this->getMessageSnapshot();
if (snapshot.size() == 0)
{
// There are no messages in this channel yet so we can just insert them
// at the front in order
this->messages_.pushFront(messages);
this->filledInMessages.invoke(messages);
return;
}
std::unordered_set<QString> existingMessageIds;
existingMessageIds.reserve(snapshot.size());