aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vrátil <dvratil@kde.org>2016-03-06 17:40:00 (GMT)
committerDaniel Vrátil <dvratil@kde.org>2016-08-15 19:56:30 (GMT)
commit08bdf758310378a7bac442172e5e599042e44548 (patch)
tree408cd762a380e052c8dde5574d1e8aa4f4865565
parente023874cf5177a910e10a381029af932a808d9a9 (diff)
Fix connection threads cleanup on server shutdown
-rw-r--r--src/server/akonadi.cpp13
-rw-r--r--src/server/akonadi.h2
2 files changed, 7 insertions, 8 deletions
diff --git a/src/server/akonadi.cpp b/src/server/akonadi.cpp
index 5a5d54f..570d2a8 100644
--- a/src/server/akonadi.cpp
+++ b/src/server/akonadi.cpp
@@ -304,9 +304,7 @@ bool AkonadiServer::quit()
mAlreadyShutdown = true;
qCDebug(AKONADISERVER_LOG) << "terminating connection threads";
- for (int i = 0; i < mConnections.count(); ++i) {
- delete mConnections[i];
- }
+ qDeleteAll(mConnections);
mConnections.clear();
qCDebug(AKONADISERVER_LOG) << "terminating service threads";
@@ -352,10 +350,11 @@ void AkonadiServer::newCmdConnection(quintptr socketDescriptor)
return;
}
- QPointer<Connection> connection = new Connection(socketDescriptor);
- connect(connection.data(), &Connection::disconnected,
- this, [connection]() {
- delete connection.data();
+ Connection *connection = new Connection(socketDescriptor);
+ connect(connection, &Connection::disconnected,
+ this, [this, connection]() {
+ delete connection;
+ mConnections.removeOne(connection);
}, Qt::QueuedConnection);
mConnections.append(connection);
}
diff --git a/src/server/akonadi.h b/src/server/akonadi.h
index 389862b..f65d6b7 100644
--- a/src/server/akonadi.h
+++ b/src/server/akonadi.h
@@ -100,7 +100,7 @@ protected:
ItemRetrievalManager *mItemRetrieval;
SearchTaskManager *mAgentSearchManager;
QProcess *mDatabaseProcess;
- QVector<QPointer<Connection>> mConnections;
+ QVector<Connection *> mConnections;
SearchManager *mSearchManager;
bool mAlreadyShutdown;