diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-03-26 13:34:43 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-03-26 13:34:43 +0200 |
commit | b334872e612433aee1284561fa247127bcdeeaf8 (patch) | |
tree | db0c7761b50db385b68458d610d79d0e72207e8b | |
parent | 29f80e6e4d698217933b7bd2df90c08162416d3f (diff) | |
download | sink-b334872e612433aee1284561fa247127bcdeeaf8.tar.gz sink-b334872e612433aee1284561fa247127bcdeeaf8.zip |
Avoid triggering a fetch when a resource disconnects
-rw-r--r-- | common/queryrunner.cpp | 6 | ||||
-rw-r--r-- | common/queryrunner.h | 4 |
2 files changed, 7 insertions, 3 deletions
diff --git a/common/queryrunner.cpp b/common/queryrunner.cpp index 73ccf6d..2c50fca 100644 --- a/common/queryrunner.cpp +++ b/common/queryrunner.cpp | |||
@@ -80,7 +80,11 @@ QueryRunner<DomainType>::QueryRunner(const Sink::Query &query, const Sink::Resou | |||
80 | mResourceAccess->open(); | 80 | mResourceAccess->open(); |
81 | QObject::connect(mResourceAccess.data(), &Sink::ResourceAccess::revisionChanged, this, &QueryRunner::revisionChanged); | 81 | QObject::connect(mResourceAccess.data(), &Sink::ResourceAccess::revisionChanged, this, &QueryRunner::revisionChanged); |
82 | // open is not synchronous, so from the time when the initial query is started until we have started and connected to the resource, it's possible to miss updates. We therefore unconditionally try to fetch new entities once we are connected. | 82 | // open is not synchronous, so from the time when the initial query is started until we have started and connected to the resource, it's possible to miss updates. We therefore unconditionally try to fetch new entities once we are connected. |
83 | QObject::connect(mResourceAccess.data(), &Sink::ResourceAccess::ready, this, &QueryRunner::revisionChanged); | 83 | QObject::connect(mResourceAccess.data(), &Sink::ResourceAccess::ready, this, [this] (bool ready) { |
84 | if (ready) { | ||
85 | revisionChanged(); | ||
86 | } | ||
87 | }); | ||
84 | } | 88 | } |
85 | mResultProvider->onDone([this]() { | 89 | mResultProvider->onDone([this]() { |
86 | delete this; | 90 | delete this; |
diff --git a/common/queryrunner.h b/common/queryrunner.h index af54619..35093e2 100644 --- a/common/queryrunner.h +++ b/common/queryrunner.h | |||
@@ -50,7 +50,7 @@ protected slots: | |||
50 | /** | 50 | /** |
51 | * Rerun query with new revision | 51 | * Rerun query with new revision |
52 | */ | 52 | */ |
53 | void revisionChanged(qint64 newRevision) | 53 | void revisionChanged() |
54 | { | 54 | { |
55 | run().exec(); | 55 | run().exec(); |
56 | } | 56 | } |
@@ -59,7 +59,7 @@ private: | |||
59 | /** | 59 | /** |
60 | * Starts query | 60 | * Starts query |
61 | */ | 61 | */ |
62 | KAsync::Job<void> run(qint64 newRevision = 0) | 62 | KAsync::Job<void> run() |
63 | { | 63 | { |
64 | return queryFunction(); | 64 | return queryFunction(); |
65 | } | 65 | } |