From ef9a070c10dffc346b7dee0c7714d7bda7663017 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 30 Jun 2016 15:13:10 +0200 Subject: Properly track changes applied by preprocessors This is necessary so we get the actual changeset during replay, so a mark-as-read action doesn't result in a new mime message, but only the flag change. --- common/bufferadaptor.h | 14 ++++++++++++++ common/pipeline.cpp | 5 +++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/common/bufferadaptor.h b/common/bufferadaptor.h index ad50582..2a40d18 100644 --- a/common/bufferadaptor.h +++ b/common/bufferadaptor.h @@ -82,15 +82,29 @@ public: } virtual void setProperty(const QByteArray &key, const QVariant &value) { + if (value != mValues.value(key)) { + mChanges << key; + } mValues.insert(key, value); } + virtual QByteArrayList availableProperties() const { return mValues.keys(); } + void resetChangedProperties() + { + mChanges.clear(); + } + + QList changedProperties() const + { + return mChanges; + } private: QHash mValues; + QList mChanges; }; } } diff --git a/common/pipeline.cpp b/common/pipeline.cpp index 976a83f..c6d5297 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp @@ -305,7 +305,7 @@ KAsync::Job Pipeline::modifiedEntity(void const *command, size_t size) // Apply diff // FIXME only apply the properties that are available in the buffer - Trace() << "Applying changed properties: " << diff->availableProperties(); + Trace() << "Applying changed properties: " << changeset; for (const auto &property : changeset) { const auto value = diff->getProperty(property); if (value.isValid()) { @@ -320,6 +320,7 @@ KAsync::Job Pipeline::modifiedEntity(void const *command, size_t size) } } + newAdaptor->resetChangedProperties(); for (auto processor : d->processors[bufferType]) { processor->modifiedEntity(key, Storage::maxRevision(d->transaction) + 1, *current, *newAdaptor, d->transaction); } @@ -330,7 +331,7 @@ KAsync::Job Pipeline::modifiedEntity(void const *command, size_t size) flatbuffers::FlatBufferBuilder metadataFbb; { //We add availableProperties to account for the properties that have been changed by the preprocessors - auto modifiedProperties = BufferUtils::toVector(metadataFbb, changeset + newAdaptor->availableProperties()); + auto modifiedProperties = BufferUtils::toVector(metadataFbb, changeset + newAdaptor->changedProperties()); auto metadataBuilder = MetadataBuilder(metadataFbb); metadataBuilder.add_revision(newRevision); metadataBuilder.add_operation(Operation_Modification); -- cgit v1.2.3