Commit c8212dd0 authored by Daniel Vrátil's avatar Daniel Vrátil 🤖

ItemSerializerPlugin: fix apply() after merging V2 into V1

We have to use the method that was marked as "old-school" in the
original code, because unlike the "new-school" one, it preserved
payload version.
parent 3528935d
......@@ -55,17 +55,19 @@ QSet<QByteArray> ItemSerializerPlugin::availableParts(const Item &item) const
void ItemSerializerPlugin::apply(Item &item, const Item &other)
{
QBuffer buffer;
QByteArray data(other.payloadData());
buffer.setBuffer(&data);
buffer.open(QIODevice::ReadOnly);
foreach (const QByteArray &part, other.loadedPayloadParts()) {
Q_FOREACH (const QByteArray &part, other.loadedPayloadParts()) {
QByteArray partData;
QBuffer buffer;
buffer.setBuffer(&partData);
buffer.open(QIODevice::ReadWrite);
buffer.seek(0);
int version;
// NOTE: we can't just pass other.payloadData() into deserialize(),
// because that does not preserve payload version.
serialize(other, part, buffer, version);
buffer.seek(0);
deserialize(item, part, buffer, 0);
deserialize(item, part, buffer, version);
}
buffer.close();
}
QSet<QByteArray> ItemSerializerPlugin::allowedForeignParts(const Item &item) const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment