From c799105ca6b4107fa19de9845247f1f3322ea6ef Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Tue, 22 Nov 2016 14:27:37 +0100 Subject: Ensure we always process the full queue and that flushing works. --- common/synchronizer.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'common/synchronizer.cpp') diff --git a/common/synchronizer.cpp b/common/synchronizer.cpp index 8010689..5bde597 100644 --- a/common/synchronizer.cpp +++ b/common/synchronizer.cpp @@ -287,11 +287,15 @@ KAsync::Job Synchronizer::processSyncQueue() mSyncStore.clear(); mMessageQueue->commit(); mSyncInProgress = false; + if (allChangesReplayed()) { + emit changesReplayed(); + } if (error) { SinkWarning() << "Error during sync: " << error.errorMessage; return KAsync::error(error); } - return KAsync::null(); + //In case we got more requests meanwhile. + return processSyncQueue(); }); } @@ -414,6 +418,15 @@ KAsync::Job Synchronizer::replay(const ApplicationDomain::Folder &, return KAsync::null(); } +bool Synchronizer::allChangesReplayed() +{ + if (!mSyncRequestQueue.isEmpty()) { + SinkTrace() << "Queue is not empty"; + return false; + } + return ChangeReplay::allChangesReplayed(); +} + #define REGISTER_TYPE(T) \ template void Synchronizer::createOrModify(const QByteArray &bufferType, const QByteArray &remoteId, const T &entity, const QHash &mergeCriteria); \ template void Synchronizer::modify(const T &entity); -- cgit v1.2.3