summaryrefslogtreecommitdiffstats
path: root/common/resourcefacade.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-07 12:10:43 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-07-07 12:10:43 +0200
commit74610b153e6929d33ef61ebe6443c81dfd32d8a1 (patch)
tree6e9891f09fb558982030598c954702cde3cba145 /common/resourcefacade.cpp
parent7ac1e222090ecfaa27ea8de2950e8c98a5033137 (diff)
downloadsink-74610b153e6929d33ef61ebe6443c81dfd32d8a1.tar.gz
sink-74610b153e6929d33ef61ebe6443c81dfd32d8a1.zip
Disconnect one the object is gone.
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());