mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
made ircmanager::connection a shared_pointer
This commit is contained in:
parent
1d1c98ecdb
commit
3c8d2740de
|
@ -15,9 +15,7 @@ Channels::getItems()
|
|||
{
|
||||
QMutexLocker locker(&Channels::channelsMutex);
|
||||
|
||||
int size = Channels::channels.size();
|
||||
|
||||
std::vector<std::shared_ptr<Channel>> items(size);
|
||||
std::vector<std::shared_ptr<Channel>> items;
|
||||
|
||||
for (auto &item : Channels::channels.values()) {
|
||||
items.push_back(std::get<0>(item));
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
namespace chatterino {
|
||||
|
||||
Account *IrcManager::account = nullptr;
|
||||
IrcConnection *IrcManager::connection = NULL;
|
||||
std::shared_ptr<IrcConnection> IrcManager::connection;
|
||||
QMutex IrcManager::connectionMutex;
|
||||
long IrcManager::connectionGeneration = 0;
|
||||
const QString IrcManager::defaultClientId = "7ue61iz46fz11y3cugd0l3tawb4taal";
|
||||
|
@ -136,9 +136,8 @@ IrcManager::beginConnecting()
|
|||
|
||||
IrcManager::connectionMutex.lock();
|
||||
if (generation == IrcManager::connectionGeneration) {
|
||||
delete IrcManager::connection;
|
||||
c->moveToThread(QCoreApplication::instance()->thread());
|
||||
IrcManager::connection = c;
|
||||
IrcManager::connection = std::shared_ptr<IrcConnection>(c);
|
||||
|
||||
auto channels = Channels::getItems();
|
||||
|
||||
|
@ -156,9 +155,8 @@ IrcManager::disconnect()
|
|||
{
|
||||
IrcManager::connectionMutex.lock();
|
||||
|
||||
if (IrcManager::connection != NULL) {
|
||||
delete IrcManager::connection;
|
||||
IrcManager::connection = NULL;
|
||||
if (IrcManager::connection.get() != NULL) {
|
||||
IrcManager::connection = std::shared_ptr<IrcConnection>();
|
||||
}
|
||||
|
||||
IrcManager::connectionMutex.unlock();
|
||||
|
|
|
@ -52,7 +52,7 @@ private:
|
|||
|
||||
static void beginConnecting();
|
||||
|
||||
static IrcConnection *connection;
|
||||
static std::shared_ptr<IrcConnection> connection;
|
||||
static QMutex connectionMutex;
|
||||
static long connectionGeneration;
|
||||
|
||||
|
|
Loading…
Reference in a new issue