From c4ec8fbc9f95a67079bc011c6455c3de72fa8266 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 14 Jan 2016 18:13:56 +0100 Subject: Ensure that we only emit ChildrenFetched once. ...Once all resource are done, and not only one. --- common/resultprovider.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'common') diff --git a/common/resultprovider.h b/common/resultprovider.h index 7f090e9..a064ab5 100644 --- a/common/resultprovider.h +++ b/common/resultprovider.h @@ -346,8 +346,14 @@ public: emitter->onRemoved([this](const DomainType &value) { this->remove(value); }); - emitter->onInitialResultSetComplete([this](const DomainType &value) { - this->initialResultSetComplete(value); + auto ptr = emitter.data(); + emitter->onInitialResultSetComplete([this, ptr](const DomainType &parent) { + auto hashValue = qHash(parent); + mInitialResultSetInProgress.remove(hashValue, ptr); + //Normally a parent is only in a single resource, except the toplevel (invalid) parent + if (!mInitialResultSetInProgress.contains(hashValue)) { + this->initialResultSetComplete(parent); + } }); emitter->onComplete([this]() { this->complete(); @@ -365,6 +371,7 @@ public: this->initialResultSetComplete(parent); } else { for (const auto &emitter : mEmitter) { + mInitialResultSetInProgress.insert(qHash(parent), emitter.data()); emitter->fetch(parent); } } @@ -372,6 +379,7 @@ public: private: QList::Ptr> mEmitter; + QMultiMap*> mInitialResultSetInProgress; }; -- cgit v1.2.3