Git commit 9c8e4612403fc2accc26ac2b49670394972f1293 by Christian Mollekopf. Committed on 08/12/2016 at 16:43. Pushed by cmollekopf into branch 'develop'. One copy algorithm is enough. M +0 -13 common/bufferadaptor.h M +3 -2 common/domain/applicationdomaintype.h M +2 -1 common/pipeline.cpp https://commits.kde.org/sink/9c8e4612403fc2accc26ac2b49670394972f1293 diff --git a/common/bufferadaptor.h b/common/bufferadaptor.h index 8787d39..f6994d7 100644 --- a/common/bufferadaptor.h +++ b/common/bufferadaptor.h @@ -59,19 +59,6 @@ public: { } = - MemoryBufferAdaptor(const BufferAdaptor &buffer, const QList &properties) : BufferAdaptor() - { - if (properties.isEmpty()) { - for (const auto &property : buffer.availableProperties()) { - mValues.insert(property, buffer.getProperty(property)); - } - } else { - for (const auto &property : properties) { - mValues.insert(property, buffer.getProperty(property)); - } - } - } - virtual ~MemoryBufferAdaptor() { } diff --git a/common/domain/applicationdomaintype.h b/common/domain/applicat= iondomaintype.h index be14513..7c3800d 100644 --- a/common/domain/applicationdomaintype.h +++ b/common/domain/applicationdomaintype.h @@ -122,7 +122,7 @@ struct Reference { QByteArray value; }; = -void copyBuffer(Sink::ApplicationDomain::BufferAdaptor &buffer, Sink::Appl= icationDomain::BufferAdaptor &memoryAdaptor, const QList &prope= rties, bool copyBlobs, bool pruneReferences); +void copyBuffer(Sink::ApplicationDomain::BufferAdaptor &buffer, Sink::Appl= icationDomain::BufferAdaptor &memoryAdaptor, const QList &prope= rties =3D QList(), bool copyBlobs =3D false, bool pruneReferenc= es =3D false); = /** * The domain type interface has two purposes: @@ -155,7 +155,8 @@ public: template static typename DomainType::Ptr getInMemoryRepresentation(const Applic= ationDomainType &domainType, const QList properties =3D QList()) { - auto memoryAdaptor =3D QSharedPointer::create(*(domainType.mAdaptor), properties); + auto memoryAdaptor =3D QSharedPointer::create(); + copyBuffer(*(domainType.mAdaptor), *memoryAdaptor, properties, fal= se, false); //mIdentifier internally still refers to the memory-mapped memory,= we need to copy the memory or it will become invalid return QSharedPointer::create(domainType.mResourceInst= anceIdentifier, QByteArray(domainType.mIdentifier.constData(), domainType.m= Identifier.size()), domainType.mRevision, memoryAdaptor); } diff --git a/common/pipeline.cpp b/common/pipeline.cpp index 7ee4b91..0eb6df5 100644 --- a/common/pipeline.cpp +++ b/common/pipeline.cpp @@ -168,7 +168,8 @@ KAsync::Job Pipeline::newEntity(void const *com= mand, size_t size) } = auto adaptor =3D adaptorFactory->createAdaptor(*entity); - auto memoryAdaptor =3D QSharedPointer::create(*(adaptor), adaptor->availableProperties()); + auto memoryAdaptor =3D QSharedPointer::create(); + Sink::ApplicationDomain::copyBuffer(*adaptor, *memoryAdaptor); = d->revisionChanged =3D true; auto revision =3D d->entityStore.maxRevision();