aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vrátil <[email protected]>2017-04-06 10:20:02 +0200
committerDaniel Vrátil <[email protected]>2017-04-06 10:20:04 +0200
commitc8212dd0a87eae8c16bc2ecfb85751bc8a9ccc09 (patch)
tree6a8ac8626b3f15fda7ab9e269488b2de1b6c9680
parent3528935dafeed2aa06099d9e33f827980bbe39c9 (diff)
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.
-rw-r--r--src/core/itemserializerplugin.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/core/itemserializerplugin.cpp b/src/core/itemserializerplugin.cpp
index b8a2d3e..cb014ea 100644
--- a/src/core/itemserializerplugin.cpp
+++ b/src/core/itemserializerplugin.cpp
@@ -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