mirror of https://github.com/qt/qtgrpc.git
Deduplicate preserveUnknownFields variable
Remove the duplicated preserveUnknownFields variable in QProtobufSerializerImpl, use the parent pointer to acquire its value instead. Pick-to: 6.8 6.9 Task-number: QTBUG-128812 Change-Id: I8c81e5ea6565f056756703d5ca989b67d163dd19 Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
This commit is contained in:
parent
4018090d1e
commit
0ef57fd3ad
|
|
@ -172,6 +172,11 @@ findIntegratedTypeHandler(QMetaType metaType, bool nonPacked)
|
|||
}
|
||||
} // namespace
|
||||
|
||||
QProtobufSerializerImpl::QProtobufSerializerImpl(QProtobufSerializerPrivate *parent) : m_parent(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QProtobufSerializerImpl::~QProtobufSerializerImpl() = default;
|
||||
|
||||
void QProtobufSerializerImpl::reset()
|
||||
|
|
@ -182,7 +187,7 @@ void QProtobufSerializerImpl::reset()
|
|||
|
||||
void QProtobufSerializerImpl::serializeUnknownFields(const QProtobufMessage *message)
|
||||
{
|
||||
if (preserveUnknownFields) {
|
||||
if (m_parent->preserveUnknownFields) {
|
||||
// Restore any unknown fields we have stored away:
|
||||
for (const auto &fields :
|
||||
std::as_const(QProtobufMessagePrivate::get(message)->unknownEntries)) {
|
||||
|
|
@ -498,7 +503,7 @@ bool QProtobufDeserializerImpl::decodeHeader(QProtobufSelfcheckIterator &it, int
|
|||
|| wireType == QtProtobuf::WireTypes::LengthDelimited);
|
||||
}
|
||||
|
||||
QProtobufSerializerPrivate::QProtobufSerializerPrivate() : deserializer(this)
|
||||
QProtobufSerializerPrivate::QProtobufSerializerPrivate() : serializer(this), deserializer(this)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -566,7 +571,6 @@ QString QProtobufSerializer::lastErrorString() const
|
|||
*/
|
||||
void QProtobufSerializer::shouldPreserveUnknownFields(bool preserveUnknownFields)
|
||||
{
|
||||
d_ptr->serializer.preserveUnknownFields = preserveUnknownFields;
|
||||
d_ptr->preserveUnknownFields = preserveUnknownFields;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ QT_BEGIN_NAMESPACE
|
|||
class QProtobufSerializerImpl final : public QProtobufSerializerBase
|
||||
{
|
||||
public:
|
||||
QProtobufSerializerImpl() = default;
|
||||
explicit QProtobufSerializerImpl(QProtobufSerializerPrivate *parent);
|
||||
~QProtobufSerializerImpl();
|
||||
|
||||
const QByteArray &result() const { return m_result; }
|
||||
|
|
@ -47,7 +47,7 @@ public:
|
|||
void reset();
|
||||
void serializeUnknownFields(const QProtobufMessage *message);
|
||||
|
||||
bool preserveUnknownFields = true;
|
||||
QProtobufSerializerPrivate *m_parent = nullptr;
|
||||
|
||||
private:
|
||||
bool serializeEnum(QVariant &value,
|
||||
|
|
|
|||
Loading…
Reference in New Issue