summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vrátil <dvratil@kde.org>2016-09-18 16:17:19 (GMT)
committerDaniel Vrátil <dvratil@kde.org>2016-09-18 16:17:19 (GMT)
commit6c93d25330b5d1392c71eaa099cdce045f70cca8 (patch)
tree7427eadf5c509f34795b6490bd3b6bf007da5c01
parentd9f3ff0465abca616971567ebd042b224891d2fc (diff)
Don't create a QPointer for a QObject in destruction
This hits an assert in Qt and potentially crashes.
-rw-r--r--src/server/notificationmanager.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/server/notificationmanager.cpp b/src/server/notificationmanager.cpp
index 01bc464..e3e9c39 100644
--- a/src/server/notificationmanager.cpp
+++ b/src/server/notificationmanager.cpp
@@ -87,7 +87,16 @@ void NotificationManager::registerConnection(quintptr socketDescriptor)
qCDebug(AKONADISERVER_LOG) << "New notification connection (registered as" << subscriber << ")";
connect(subscriber, &QObject::destroyed,
this, [this, subscriber]() {
- mSubscribers.removeOne(subscriber);
+ // Can't use mSubscribers.remove() because that would try to create
+ // a QPointer for the subscriber pointer triggering a Q_ASSERT in Qt
+ // (see QtSharedPointer::ExternalRefCountData::getAndRef)
+ auto it = std::find_if(mSubscribers.begin(), mSubscribers.end(),
+ [subscriber](const QPointer<NotificationSubscriber> &qptr) {
+ return qptr.data() == subscriber;
+ });
+ if (it != mSubscribers.end()) {
+ mSubscribers.erase(it);
+ }
});
connect(subscriber, &NotificationSubscriber::notificationDebuggingChanged,
this, [this](bool enabled) {