made ircmanager::connection a shared_pointer
This commit is contained in:
+1
-3
@@ -15,9 +15,7 @@ Channels::getItems()
|
|||||||
{
|
{
|
||||||
QMutexLocker locker(&Channels::channelsMutex);
|
QMutexLocker locker(&Channels::channelsMutex);
|
||||||
|
|
||||||
int size = Channels::channels.size();
|
std::vector<std::shared_ptr<Channel>> items;
|
||||||
|
|
||||||
std::vector<std::shared_ptr<Channel>> items(size);
|
|
||||||
|
|
||||||
for (auto &item : Channels::channels.values()) {
|
for (auto &item : Channels::channels.values()) {
|
||||||
items.push_back(std::get<0>(item));
|
items.push_back(std::get<0>(item));
|
||||||
|
|||||||
+4
-6
@@ -15,7 +15,7 @@
|
|||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
Account *IrcManager::account = nullptr;
|
Account *IrcManager::account = nullptr;
|
||||||
IrcConnection *IrcManager::connection = NULL;
|
std::shared_ptr<IrcConnection> IrcManager::connection;
|
||||||
QMutex IrcManager::connectionMutex;
|
QMutex IrcManager::connectionMutex;
|
||||||
long IrcManager::connectionGeneration = 0;
|
long IrcManager::connectionGeneration = 0;
|
||||||
const QString IrcManager::defaultClientId = "7ue61iz46fz11y3cugd0l3tawb4taal";
|
const QString IrcManager::defaultClientId = "7ue61iz46fz11y3cugd0l3tawb4taal";
|
||||||
@@ -136,9 +136,8 @@ IrcManager::beginConnecting()
|
|||||||
|
|
||||||
IrcManager::connectionMutex.lock();
|
IrcManager::connectionMutex.lock();
|
||||||
if (generation == IrcManager::connectionGeneration) {
|
if (generation == IrcManager::connectionGeneration) {
|
||||||
delete IrcManager::connection;
|
|
||||||
c->moveToThread(QCoreApplication::instance()->thread());
|
c->moveToThread(QCoreApplication::instance()->thread());
|
||||||
IrcManager::connection = c;
|
IrcManager::connection = std::shared_ptr<IrcConnection>(c);
|
||||||
|
|
||||||
auto channels = Channels::getItems();
|
auto channels = Channels::getItems();
|
||||||
|
|
||||||
@@ -156,9 +155,8 @@ IrcManager::disconnect()
|
|||||||
{
|
{
|
||||||
IrcManager::connectionMutex.lock();
|
IrcManager::connectionMutex.lock();
|
||||||
|
|
||||||
if (IrcManager::connection != NULL) {
|
if (IrcManager::connection.get() != NULL) {
|
||||||
delete IrcManager::connection;
|
IrcManager::connection = std::shared_ptr<IrcConnection>();
|
||||||
IrcManager::connection = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
IrcManager::connectionMutex.unlock();
|
IrcManager::connectionMutex.unlock();
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@ private:
|
|||||||
|
|
||||||
static void beginConnecting();
|
static void beginConnecting();
|
||||||
|
|
||||||
static IrcConnection *connection;
|
static std::shared_ptr<IrcConnection> connection;
|
||||||
static QMutex connectionMutex;
|
static QMutex connectionMutex;
|
||||||
static long connectionGeneration;
|
static long connectionGeneration;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user