diff --git a/src/ircmanager.cpp b/src/ircmanager.cpp index 7b3a3c47f..fcf6ddedd 100644 --- a/src/ircmanager.cpp +++ b/src/ircmanager.cpp @@ -159,7 +159,7 @@ void IrcManager::beginConnecting() Communi::IrcConnection *_writeConnection = this->createConnection(false); Communi::IrcConnection *_readConnection = this->createConnection(true); - QMutexLocker locker(&_connectionMutex); + std::lock_guard locker(this->connectionMutex); if (generation == this->connectionGeneration) { this->writeConnection = std::shared_ptr(_writeConnection); @@ -183,7 +183,7 @@ void IrcManager::beginConnecting() void IrcManager::disconnect() { - _connectionMutex.lock(); + this->connectionMutex.lock(); auto _readConnection = this->readConnection; auto _writeConnection = this->writeConnection; @@ -191,43 +191,43 @@ void IrcManager::disconnect() this->readConnection.reset(); this->writeConnection.reset(); - _connectionMutex.unlock(); + this->connectionMutex.unlock(); } void IrcManager::sendMessage(const QString &channelName, const QString &message) { - _connectionMutex.lock(); + this->connectionMutex.lock(); if (this->writeConnection) { this->writeConnection->sendRaw("PRIVMSG #" + channelName + " :" + message); } - _connectionMutex.unlock(); + this->connectionMutex.unlock(); } void IrcManager::joinChannel(const QString &channelName) { - _connectionMutex.lock(); + this->connectionMutex.lock(); if (this->readConnection && this->writeConnection) { this->readConnection->sendRaw("JOIN #" + channelName); this->writeConnection->sendRaw("JOIN #" + channelName); } - _connectionMutex.unlock(); + this->connectionMutex.unlock(); } void IrcManager::partChannel(const QString &channelName) { - _connectionMutex.lock(); + this->connectionMutex.lock(); if (this->readConnection && this->writeConnection) { this->readConnection->sendRaw("PART #" + channelName); this->writeConnection->sendRaw("PART #" + channelName); } - _connectionMutex.unlock(); + this->connectionMutex.unlock(); } void IrcManager::messageReceived(Communi::IrcMessage *message) @@ -239,8 +239,8 @@ void IrcManager::messageReceived(Communi::IrcMessage *message) qDebug() << "Param: " << param; } - const QString &command = message->command(); /* + const QString &command = message->command(); if (command == "CLEARCHAT") { } else if (command == "ROOMSTATE") { diff --git a/src/ircmanager.h b/src/ircmanager.h index e212af285..744f6bc4c 100644 --- a/src/ircmanager.h +++ b/src/ircmanager.h @@ -12,6 +12,7 @@ #include #include +#include namespace chatterino { @@ -56,7 +57,7 @@ private: std::shared_ptr writeConnection = nullptr; std::shared_ptr readConnection = nullptr; - QMutex _connectionMutex; + std::mutex connectionMutex; uint32_t connectionGeneration = 0; QMap _twitchBlockedUsers;