From b334872e612433aee1284561fa247127bcdeeaf8 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Mon, 26 Mar 2018 13:34:43 +0200 Subject: Avoid triggering a fetch when a resource disconnects --- common/queryrunner.cpp | 6 +++++- 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::QueryRunner(const Sink::Query &query, const Sink::Resou mResourceAccess->open(); QObject::connect(mResourceAccess.data(), &Sink::ResourceAccess::revisionChanged, this, &QueryRunner::revisionChanged); // 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. - QObject::connect(mResourceAccess.data(), &Sink::ResourceAccess::ready, this, &QueryRunner::revisionChanged); + QObject::connect(mResourceAccess.data(), &Sink::ResourceAccess::ready, this, [this] (bool ready) { + if (ready) { + revisionChanged(); + } + }); } mResultProvider->onDone([this]() { 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: /** * Rerun query with new revision */ - void revisionChanged(qint64 newRevision) + void revisionChanged() { run().exec(); } @@ -59,7 +59,7 @@ private: /** * Starts query */ - KAsync::Job run(qint64 newRevision = 0) + KAsync::Job run() { return queryFunction(); } -- cgit v1.2.3