summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vrátil <dvratil@kde.org>2016-09-07 15:43:17 (GMT)
committerDaniel Vrátil <dvratil@kde.org>2016-09-07 15:43:17 (GMT)
commitfc487710a5a2486a58e29832b02334287497e270 (patch)
treeebeeb9c76255857a060dfa495c075c2c93f095dd
parentfa3ee6c55654be79a70757bee1a518c036f57d4a (diff)
Fix server crash on shutdown
-rw-r--r--src/server/notificationmanager.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/server/notificationmanager.cpp b/src/server/notificationmanager.cpp
index ed7da6a..e5617cd 100644
--- a/src/server/notificationmanager.cpp
+++ b/src/server/notificationmanager.cpp
@@ -43,10 +43,12 @@ NotificationManager::NotificationManager()
, mNotifyThreadPool(Q_NULLPTR)
, mDebugNotifications(0)
{
+ setObjectName(QStringLiteral("NotificationManager"));
}
NotificationManager::~NotificationManager()
{
+ quitThread();
}
void NotificationManager::init()
@@ -68,9 +70,17 @@ void NotificationManager::init()
void NotificationManager::quit()
{
- AkThread::quit();
-
+ mNotifyThreadPool->clear();
+ mNotifyThreadPool->waitForDone();
+ delete mTimer;
+ delete mNotifyThreadPool;
qDeleteAll(mSubscribers);
+ // FIXME: There seems to be a QTimer somewhere that we must delete here,
+ // otherwise we get "Can't stop QTimer from a different thread" warning
+ // from QObject::~QObject()
+ qDeleteAll(children());
+
+ AkThread::quit();
}
void NotificationManager::registerConnection(quintptr socketDescriptor)
@@ -80,7 +90,7 @@ void NotificationManager::registerConnection(quintptr socketDescriptor)
NotificationSubscriber *subscriber = new NotificationSubscriber(this, socketDescriptor);
qCDebug(AKONADISERVER_LOG) << "New notification connection (registered as" << subscriber << ")";
connect(subscriber, &QObject::destroyed,
- [this, subscriber]() {
+ this, [this, subscriber]() {
mSubscribers.removeOne(subscriber);
});
connect(subscriber, &NotificationSubscriber::notificationDebuggingChanged,
@@ -105,6 +115,8 @@ void NotificationManager::connectNotificationCollector(NotificationCollector *co
void NotificationManager::slotNotify(const Protocol::ChangeNotification::List &msgs)
{
+ Q_ASSERT(QThread::currentThread() == thread());
+
Q_FOREACH (const Protocol::ChangeNotification &msg, msgs) {
if (msg.type() == Protocol::Command::CollectionChangeNotification) {
Protocol::CollectionChangeNotification::appendAndCompress(mNotifications, msg);