fix crash in name-colorizer

This commit is contained in:
Rasmus Karlsson 2019-08-11 22:18:01 +02:00
parent cd5972522b
commit e56c90c33d
2 changed files with 15 additions and 4 deletions

View file

@ -502,17 +502,27 @@ void TwitchMessageBuilder::appendChannelName()
->setLink(link); ->setLink(link);
} }
void TwitchMessageBuilder::parseUsername() void TwitchMessageBuilder::parseUsernameColor()
{ {
const auto iterator = this->tags.find("color"); const auto iterator = this->tags.find("color");
if (const auto color = iterator.value().toString(); !color.isEmpty()) if (iterator != this->tags.end())
{ {
this->usernameColor_ = QColor(color); if (const auto color = iterator.value().toString(); !color.isEmpty())
{
this->usernameColor_ = QColor(color);
return;
}
} }
else if (getSettings()->colorizeNicknames && this->tags.contains("user-id"))
if (getSettings()->colorizeNicknames && this->tags.contains("user-id"))
{ {
this->usernameColor_ = getRandomColor(this->tags.value("user-id")); this->usernameColor_ = getRandomColor(this->tags.value("user-id"));
} }
}
void TwitchMessageBuilder::parseUsername()
{
this->parseUsernameColor();
// username // username
this->userName = this->ircMessage->nick(); this->userName = this->ircMessage->nick();

View file

@ -52,6 +52,7 @@ private:
void parseMessageID(); void parseMessageID();
void parseRoomID(); void parseRoomID();
void appendChannelName(); void appendChannelName();
void parseUsernameColor();
void parseUsername(); void parseUsername();
void appendUsername(); void appendUsername();
void runIgnoreReplaces( void runIgnoreReplaces(