mirror of https://github.com/qt/qtgrpc.git
Assert if QGrpcOperationContext::serializer returns null
QGrpcOperationContext shall be constructed with the valid serializer. Let's avoid unnecessary error handling and assert if QGrpcOperationContext doesn't contain a valid pointer to a serializer. [ChangeLog][Grpc] QAbstractGrpcChannel implementations now are obliged to supply QGrpcContext with the valid serializer. Any attempt to deserialize the returned message with null serializer now will lead to assert or SEGV. Pick-to: 6.8 Change-Id: I1f9142244bf5b5ba7a3d04965649d0a0fbb143b9 Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
This commit is contained in:
parent
a82ac155d7
commit
271764cddf
|
|
@ -116,7 +116,8 @@ bool QGrpcOperation::read(QProtobufMessage *message) const
|
||||||
"Can't read to nullptr QProtobufMessage");
|
"Can't read to nullptr QProtobufMessage");
|
||||||
Q_D(const QGrpcOperation);
|
Q_D(const QGrpcOperation);
|
||||||
const auto ser = d->operationContext->serializer();
|
const auto ser = d->operationContext->serializer();
|
||||||
return ser && ser->deserialize(message, d->data);
|
Q_ASSERT_X(ser, "QGrpcOperation", "The serializer is null");
|
||||||
|
return ser->deserialize(message, d->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -144,8 +145,7 @@ QAbstractProtobufSerializer::DeserializationError QGrpcOperation::deserializatio
|
||||||
{
|
{
|
||||||
Q_D(const QGrpcOperation);
|
Q_D(const QGrpcOperation);
|
||||||
const auto ser = d->operationContext->serializer();
|
const auto ser = d->operationContext->serializer();
|
||||||
if (!ser)
|
Q_ASSERT_X(ser, "QGrpcOperation", "The serializer is null");
|
||||||
return QAbstractProtobufSerializer::NoDeserializerError;
|
|
||||||
return ser->deserializationError();
|
return ser->deserializationError();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -160,8 +160,7 @@ QString QGrpcOperation::deserializationErrorString() const
|
||||||
{
|
{
|
||||||
Q_D(const QGrpcOperation);
|
Q_D(const QGrpcOperation);
|
||||||
const auto ser = d->operationContext->serializer();
|
const auto ser = d->operationContext->serializer();
|
||||||
if (!ser)
|
Q_ASSERT_X(ser, "QGrpcOperation", "The serializer is null");
|
||||||
return QStringLiteral("serializer not available");
|
|
||||||
return ser->deserializationErrorString();
|
return ser->deserializationErrorString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue