Fix crash when receiving whisper (#2298)

PR #2284 introduced this bug: whispers aren't linked to a twitch channel
but we're storing user colors in a twitch channel. So, dereferencing
a nullptr. Not good.
This commit is contained in:
Wolf Clément 2020-12-20 09:38:34 +01:00 committed by GitHub
parent fea52faa66
commit b8104863a5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -72,7 +72,7 @@ void ChannelChatters::setChatters(UsernameSet &&set)
const QColor ChannelChatters::getUserColor(const QString &user) const QColor ChannelChatters::getUserColor(const QString &user)
{ {
const auto chatterColors = this->chatterColors_.access(); const auto chatterColors = this->chatterColors_.accessConst();
const auto search = chatterColors->find(user.toLower()); const auto search = chatterColors->find(user.toLower());
if (search == chatterColors->end()) if (search == chatterColors->end())

View file

@ -600,7 +600,10 @@ void TwitchMessageBuilder::parseUsername()
// } // }
this->message().loginName = this->userName; this->message().loginName = this->userName;
if (this->twitchChannel != nullptr)
{
this->twitchChannel->setUserColor(this->userName, this->usernameColor_); this->twitchChannel->setUserColor(this->userName, this->usernameColor_);
}
// Update current user color if this is our message // Update current user color if this is our message
auto currentUser = getApp()->accounts->twitch.getCurrent(); auto currentUser = getApp()->accounts->twitch.getCurrent();