-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.7.3, 6.8.4
-
-
c764a9b22 (dev), 9370589e0 (6.10), cc3a18811 (6.9), e354582c0 (tqtc/lts-6.8)
-
Foundation PM Staging
proto messages with repeated fields of enum-types are not serialized correctly.
We had to replace all such occurrences with repeated int32 fields in order to to get correct binary data.
Example proto-file repeatedenums.proto:
package qtbugs;
enum TestEnum {
One = 1;
Two = 2;
Three = 3;
}
message TestMessage {
repeated TestEnum state = 1;
}
Example program:
The following sample program will write the binary data to a file:
QProtobufSerializer serializer;
qtbugs::TestMessage message;
message.state().append(qtbugs::TestEnumGadget::One);
message.state().append(qtbugs::TestEnumGadget::Two);
message.state().append(qtbugs::TestEnumGadget::Three);
QByteArray rawData = message.serialize(&serializer);
qInfo() << rawData;
QFile file{"testmessage.protobuf"};
file.open(QIODevice::WriteOnly);
file.write(rawData);
Expected output as obtained via "protoc --decode_raw < testmessage.protobuf":
1: 1
1: 2
1: 3
Actual output as obtained via "protoc --decode_raw < testmessage.protobuf":
1: "\000\001\002"