From 1b4c24e0a82d46aba9fd7a1ed6b142d2cc9b0434 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 20 Mar 2018 14:22:31 +0100 Subject: Try to fix race condition causing us to loose initial updates. The maillist sometimes misses updates, and this might be the root cause of it. Because it's difficult to test we'll just try this fix for now. --- common/queryrunner.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'common/queryrunner.cpp') diff --git a/common/queryrunner.cpp b/common/queryrunner.cpp index 2062828..73ccf6d 100644 --- a/common/queryrunner.cpp +++ b/common/queryrunner.cpp @@ -77,9 +77,10 @@ QueryRunner::QueryRunner(const Sink::Query &query, const Sink::Resou // Incremental updates are always loaded directly, leaving it up to the result to discard the changes if they are not interesting setQuery([=]() { return incrementalFetch(query, bufferType); }); // Ensure the connection is open, if it wasn't already opened - // TODO If we are not connected already, we have to check for the latest revision once connected, otherwise we could miss some updates 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); } mResultProvider->onDone([this]() { delete this; -- cgit v1.2.3