diff --git a/autotests/libs/tagtest.cpp b/autotests/libs/tagtest.cpp --- a/autotests/libs/tagtest.cpp +++ b/autotests/libs/tagtest.cpp @@ -756,10 +756,17 @@ TagCreateJob *createjob = new TagCreateJob(tag, this); AKVERIFYEXEC(createjob); createdTag = createjob->tag(); + QCOMPARE(createdTag.type(), tag.type()); + QCOMPARE(createdTag.name(), tag.name()); + QCOMPARE(createdTag.gid(), tag.gid()); //We usually pick up signals from the previous tests as well (due to server-side notification caching) QTRY_VERIFY(addedSpy.count() >= 1); QTRY_COMPARE(addedSpy.last().first().value().id(), createdTag.id()); - QVERIFY(addedSpy.last().first().value().hasAttribute()); + const Akonadi::Tag notifiedTag = addedSpy.last().first().value(); + QCOMPARE(notifiedTag.type(), createdTag.type()); + QCOMPARE(notifiedTag.gid(), createdTag.gid()); + QVERIFY(notifiedTag.hasAttribute()); + QCOMPARE(notifiedTag.name(), createdTag.name()); // requires the TagAttribute } { diff --git a/src/server/aggregatedfetchscope.h b/src/server/aggregatedfetchscope.h --- a/src/server/aggregatedfetchscope.h +++ b/src/server/aggregatedfetchscope.h @@ -49,6 +49,9 @@ bool fetchStatistics() const; void setFetchStatistics(bool fetchStats); + void addSubscriber(); + void removeSubscriber(); + private: AggregatedCollectionFetchScopePrivate * const d_ptr; Q_DECLARE_PRIVATE(AggregatedCollectionFetchScope) @@ -121,6 +124,9 @@ void addAttribute(const QByteArray &attribute); void removeAttribute(const QByteArray &attribute); + void addSubscriber(); + void removeSubscriber(); + bool fetchIdOnly() const; void setFetchIdOnly(bool fetchIdOnly); diff --git a/src/server/aggregatedfetchscope.cpp b/src/server/aggregatedfetchscope.cpp --- a/src/server/aggregatedfetchscope.cpp +++ b/src/server/aggregatedfetchscope.cpp @@ -89,6 +89,7 @@ public: QSet attrs; QHash attrsCount; + int subscribers = 0; int fetchIdOnly = 0; int fetchStats = 0; }; @@ -99,6 +100,7 @@ public: QSet attrs; QHash attrsCount; + int subscribers = 0; int fetchIdOnly = 0; int fetchRemoteId = 0; int fetchAllAttributes = 0; @@ -186,7 +188,7 @@ LOCKED_D(const AggregatedCollectionFetchScope) // Aggregation: we can return true only if everyone wants fetchIdOnly, // otherwise there's at least one subscriber who wants everything - return d->fetchIdOnly == 0; + return d->fetchIdOnly == d->subscribers; } void AggregatedCollectionFetchScope::setFetchIdOnly(bool fetchIdOnly) @@ -208,6 +210,17 @@ d->updateBool(fetchStats, d->fetchStats); } +void AggregatedCollectionFetchScope::addSubscriber() +{ + LOCKED_D(AggregatedCollectionFetchScope) + ++d->subscribers; +} + +void AggregatedCollectionFetchScope::removeSubscriber() +{ + LOCKED_D(AggregatedCollectionFetchScope) + --d->subscribers; +} AggregatedItemFetchScope::AggregatedItemFetchScope() @@ -567,7 +580,7 @@ LOCKED_D(const AggregatedTagFetchScope) // Aggregation: we can return true only if everyone wants fetchIdOnly, // otherwise there's at least one subscriber who wants everything - return d->fetchIdOnly == 0; + return d->fetchIdOnly == d->subscribers; } void AggregatedTagFetchScope::setFetchIdOnly(bool fetchIdOnly) @@ -618,4 +631,16 @@ d->removeFromSet(attribute, d->attrs, d->attrsCount); } +void AggregatedTagFetchScope::addSubscriber() +{ + LOCKED_D(AggregatedTagFetchScope) + ++d->subscribers; +} + +void AggregatedTagFetchScope::removeSubscriber() +{ + LOCKED_D(AggregatedTagFetchScope) + --d->subscribers; +} + #undef LOCKED_D diff --git a/src/server/notificationsubscriber.cpp b/src/server/notificationsubscriber.cpp --- a/src/server/notificationsubscriber.cpp +++ b/src/server/notificationsubscriber.cpp @@ -47,6 +47,10 @@ , mExclusive(false) , mNotificationDebugging(false) { + if (mManager) { + mManager->collectionFetchScope()->addSubscriber(); + mManager->tagFetchScope()->addSubscriber(); + } } NotificationSubscriber::NotificationSubscriber(NotificationManager *manager, quintptr socketDescriptor) @@ -162,6 +166,10 @@ for (const auto &attr : attrs) { cfs->removeAttribute(attr); } + cfs->removeSubscriber(); + + auto tfs = mManager->tagFetchScope(); + tfs->removeSubscriber(); mManager->forgetSubscriber(this); deleteLater(); @@ -267,6 +275,8 @@ const auto newScope = command.tagFetchScope(); mManager->tagFetchScope()->apply(mTagFetchScope, newScope); mTagFetchScope = newScope; + if (!newScope.fetchIdOnly()) + Q_ASSERT(!mManager->tagFetchScope()->fetchIdOnly()); } if (mManager) {