small refactor of twitchserver

This commit is contained in:
fourtf
2018-06-22 23:24:45 +02:00
parent 115031b7ac
commit 4aec66e3ea
5 changed files with 44 additions and 53 deletions
+3 -10
View File
@@ -186,16 +186,7 @@ std::shared_ptr<Channel> TwitchServer::getCustomChannel(const QString &channelNa
void TwitchServer::forEachChannelAndSpecialChannels(std::function<void(ChannelPtr)> func)
{
std::lock_guard<std::mutex> lock(this->channelMutex);
for (std::weak_ptr<Channel> &weak : this->channels) {
std::shared_ptr<Channel> chan = weak.lock();
if (!chan) {
continue;
}
func(chan);
}
this->forEachChannel(func);
func(this->whispersChannel);
func(this->mentionsChannel);
@@ -203,6 +194,8 @@ void TwitchServer::forEachChannelAndSpecialChannels(std::function<void(ChannelPt
std::shared_ptr<Channel> TwitchServer::getChannelOrEmptyByID(const QString &channelID)
{
this->forEachChannel();
{
std::lock_guard<std::mutex> lock(this->channelMutex);