From 69fb3652dd83151f391112cc7b313966c3d4c630 Mon Sep 17 00:00:00 2001 From: fourtf Date: Mon, 30 Jan 2017 20:13:53 +0100 Subject: [PATCH] join channels when IrcChonnection started --- ircmanager.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/ircmanager.cpp b/ircmanager.cpp index 56ad1e669..0d363cadf 100644 --- a/ircmanager.cpp +++ b/ircmanager.cpp @@ -132,9 +132,8 @@ IrcManager::beginConnecting() c->sendCommand(IrcCommand::createCapability("REQ", "twitch.tv/commands")); c->sendCommand(IrcCommand::createCapability("REQ", "twitch.tv/tags")); - c->open(); + QMutexLocker locker(&IrcManager::connectionMutex); - IrcManager::connectionMutex.lock(); if (generation == IrcManager::connectionGeneration) { c->moveToThread(QCoreApplication::instance()->thread()); IrcManager::connection = std::shared_ptr(c); @@ -142,12 +141,13 @@ IrcManager::beginConnecting() auto channels = Channels::getItems(); for (auto &channel : channels) { - IrcManager::sendJoin(channel.get()->getName()); + c->sendRaw("JOIN #" + channel.get()->getName()); } + + c->open(); } else { delete c; } - IrcManager::connectionMutex.unlock(); } void @@ -155,6 +155,7 @@ IrcManager::disconnect() { IrcManager::connectionMutex.lock(); + auto c = IrcManager::connection; if (IrcManager::connection.get() != NULL) { IrcManager::connection = std::shared_ptr(); } @@ -174,9 +175,11 @@ void IrcManager::sendJoin(const QString &channel) { IrcManager::connectionMutex.lock(); - if (IrcManager::connection != NULL) { - IrcManager::connection->sendRaw("JOIN #" + channel); + + if (IrcManager::connection.get() != NULL) { + IrcManager::connection.get()->sendRaw("JOIN #" + channel); } + IrcManager::connectionMutex.unlock(); } @@ -184,9 +187,11 @@ void IrcManager::partChannel(const QString &channel) { IrcManager::connectionMutex.lock(); - if (IrcManager::connection != NULL) { - IrcManager::connection->sendRaw("PART #" + channel); + + if (IrcManager::connection.get() != NULL) { + IrcManager::connection.get()->sendRaw("PART #" + channel); } + IrcManager::connectionMutex.unlock(); }