diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-04-27 00:38:36 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-04-27 00:38:36 +0200 |
commit | a044a7f0ea054502fb8b6aedcfa213b192a7b05a (patch) | |
tree | b13f9f501352a1251a2ced52e8a09cffb6424d9b /common/synclistresult.h | |
parent | 12539f35e385c9250cd67e387c67dbaff4de34f3 (diff) | |
download | sink-a044a7f0ea054502fb8b6aedcfa213b192a7b05a.tar.gz sink-a044a7f0ea054502fb8b6aedcfa213b192a7b05a.zip |
Fixed lifetime management of resultSet.
The resultSet remains valid for the duration of the thread.
We keep the thread running until the ResultEmitter is deleted.
Diffstat (limited to 'common/synclistresult.h')
-rw-r--r-- | common/synclistresult.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/common/synclistresult.h b/common/synclistresult.h index 5fa0efd..0a86f8c 100644 --- a/common/synclistresult.h +++ b/common/synclistresult.h | |||
@@ -19,20 +19,21 @@ class SyncListResult : public QList<T> { | |||
19 | public: | 19 | public: |
20 | SyncListResult(const QSharedPointer<ResultEmitter<T> > &emitter) | 20 | SyncListResult(const QSharedPointer<ResultEmitter<T> > &emitter) |
21 | :QList<T>(), | 21 | :QList<T>(), |
22 | mComplete(false), | ||
23 | mEmitter(emitter) | 22 | mEmitter(emitter) |
24 | { | 23 | { |
25 | emitter->onAdded([this](const T &value) { | 24 | emitter->onAdded([this](const T &value) { |
26 | this->append(value); | 25 | this->append(value); |
27 | }); | 26 | }); |
28 | emitter->onComplete([this]() { | 27 | emitter->onInitialResultSetComplete([this]() { |
29 | mComplete = true; | ||
30 | if (eventLoopAborter) { | 28 | if (eventLoopAborter) { |
31 | eventLoopAborter(); | 29 | eventLoopAborter(); |
32 | //Be safe in case of a second invocation of the complete handler | 30 | //Be safe in case of a second invocation of the complete handler |
33 | eventLoopAborter = std::function<void()>(); | 31 | eventLoopAborter = std::function<void()>(); |
34 | } | 32 | } |
35 | }); | 33 | }); |
34 | emitter->onComplete([this]() { | ||
35 | mEmitter.clear(); | ||
36 | }); | ||
36 | emitter->onClear([this]() { | 37 | emitter->onClear([this]() { |
37 | this->clear(); | 38 | this->clear(); |
38 | }); | 39 | }); |
@@ -46,7 +47,6 @@ public: | |||
46 | } | 47 | } |
47 | 48 | ||
48 | private: | 49 | private: |
49 | bool mComplete; | ||
50 | QSharedPointer<ResultEmitter<T> > mEmitter; | 50 | QSharedPointer<ResultEmitter<T> > mEmitter; |
51 | std::function<void()> eventLoopAborter; | 51 | std::function<void()> eventLoopAborter; |
52 | }; | 52 | }; |