summaryrefslogtreecommitdiffstats
path: root/common/resourcefacade.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/resourcefacade.cpp')
-rw-r--r--common/resourcefacade.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/common/resourcefacade.cpp b/common/resourcefacade.cpp
index 6e135b3..898e3ad 100644
--- a/common/resourcefacade.cpp
+++ b/common/resourcefacade.cpp
@@ -57,7 +57,7 @@ static bool matchesFilter(const QHash<QByteArray, Query::Comparator> &filter, co
57 57
58template<typename DomainType> 58template<typename DomainType>
59LocalStorageQueryRunner<DomainType>::LocalStorageQueryRunner(const Query &query, const QByteArray &identifier, ConfigNotifier &configNotifier) 59LocalStorageQueryRunner<DomainType>::LocalStorageQueryRunner(const Query &query, const QByteArray &identifier, ConfigNotifier &configNotifier)
60 : mResultProvider(new ResultProvider<typename DomainType::Ptr>), mConfigStore(identifier) 60 : mResultProvider(new ResultProvider<typename DomainType::Ptr>), mConfigStore(identifier), mGuard(new QObject)
61{ 61{
62 QObject *guard = new QObject; 62 QObject *guard = new QObject;
63 mResultProvider->setFetcher([this, query, guard, &configNotifier](const QSharedPointer<DomainType> &) { 63 mResultProvider->setFetcher([this, query, guard, &configNotifier](const QSharedPointer<DomainType> &) {
@@ -139,6 +139,11 @@ LocalStorageQueryRunner<DomainType>::LocalStorageQueryRunner(const Query &query,
139// 139//
140// } 140// }
141 141
142template<typename DomainType>
143QObject *LocalStorageQueryRunner<DomainType>::guard() const
144{
145 return mGuard.get();
146}
142 147
143template<typename DomainType> 148template<typename DomainType>
144void LocalStorageQueryRunner<DomainType>::updateStatus(DomainType &entity) 149void LocalStorageQueryRunner<DomainType>::updateStatus(DomainType &entity)
@@ -284,8 +289,7 @@ QPair<KAsync::Job<void>, typename Sink::ResultEmitter<typename ApplicationDomain
284 runner->setStatusUpdater([runner, monitoredResources](ApplicationDomain::SinkResource &resource) { 289 runner->setStatusUpdater([runner, monitoredResources](ApplicationDomain::SinkResource &resource) {
285 auto resourceAccess = ResourceAccessFactory::instance().getAccess(resource.identifier(), ResourceConfig::getResourceType(resource.identifier())); 290 auto resourceAccess = ResourceAccessFactory::instance().getAccess(resource.identifier(), ResourceConfig::getResourceType(resource.identifier()));
286 if (!monitoredResources->contains(resource.identifier())) { 291 if (!monitoredResources->contains(resource.identifier())) {
287 //TODO disconnect at some point when the runner is done 292 auto ret = QObject::connect(resourceAccess.data(), &ResourceAccess::notification, runner->guard(), [resource, runner, resourceAccess](const Notification &notification) {
288 auto ret = QObject::connect(resourceAccess.data(), &ResourceAccess::notification, [resource, runner, resourceAccess](const Notification &notification) {
289 Trace() << "Received notification in facade: " << notification.type; 293 Trace() << "Received notification in facade: " << notification.type;
290 if (notification.type == Notification::Status) { 294 if (notification.type == Notification::Status) {
291 runner->statusChanged(resource.identifier()); 295 runner->statusChanged(resource.identifier());