summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2015-04-02 17:16:47 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2015-04-02 17:16:47 +0200
commit4707e725cefbf58b9f66c860680e94e6bdb9001f (patch)
tree584a53553baac2b1571154ad24cdf06eec993ba4
parent64a3e2d9ba3fe79dee53d86a4469f760eea8fcf9 (diff)
downloadsink-4707e725cefbf58b9f66c860680e94e6bdb9001f.tar.gz
sink-4707e725cefbf58b9f66c860680e94e6bdb9001f.zip
Unbreak the clientapi.
We indeed have to keep the facade alive, otherwise this starts crashing.
-rw-r--r--common/clientapi.h14
1 files changed, 12 insertions, 2 deletions
diff --git a/common/clientapi.h b/common/clientapi.h
index aa3aab8..f015b56 100644
--- a/common/clientapi.h
+++ b/common/clientapi.h
@@ -425,8 +425,18 @@ public:
425 auto facade = FacadeFactory::instance().getFacade<DomainType>(resource); 425 auto facade = FacadeFactory::instance().getFacade<DomainType>(resource);
426 //We have to bind an instance to the function callback. Since we use a shared pointer this keeps the result provider instance (and thus also the emitter) alive. 426 //We have to bind an instance to the function callback. Since we use a shared pointer this keeps the result provider instance (and thus also the emitter) alive.
427 std::function<void(const typename DomainType::Ptr &)> addCallback = std::bind(&ResultProvider<typename DomainType::Ptr>::add, resultSet, std::placeholders::_1); 427 std::function<void(const typename DomainType::Ptr &)> addCallback = std::bind(&ResultProvider<typename DomainType::Ptr>::add, resultSet, std::placeholders::_1);
428 //We copy the facade pointer to keep it alive 428
429 job = job.then(facade->load(query, addCallback)); 429 // TODO The following is a necessary hack to keep the facade alive.
430 // Otherwise this would reduce to:
431 // job = job.then(facade->load(query, addCallback));
432 // We somehow have to guarantee that the facade remains valid for the duration of the job
433 job = job.then<void>([facade, query, addCallback](Async::Future<void> &future) {
434 Async::Job<void> j = facade->load(query, addCallback);
435 j.then<void>([&future, facade](Async::Future<void> &f) {
436 future.setFinished();
437 f.setFinished();
438 }).exec();
439 });
430 } 440 }
431 job.then<void>([/* eventloop, */resultSet](Async::Future<void> &future) { 441 job.then<void>([/* eventloop, */resultSet](Async::Future<void> &future) {
432 qDebug() << "Query complete"; 442 qDebug() << "Query complete";