Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.9.0
-
None
Description
Inside of QMetaObjectPublisher::invokeMethod, there is code to check the return type for the method and set the returnValue to the proper QVariant. However, this return value is set after the QGenericReturnArgument returnArgument object is set up, causing a crash. This can most easily seen with a method that returns a QJsonObject for example.
In previous versions of Qt the returnValue was checked and set up prior to the QGenericReturnArgument returnArgument object being created; reverting back to this order of operations fixes the issue.
Old crashing code:
QGenericReturnArgument returnArgument(method.typeName(), returnValue.data());
if (method.returnType() != QMetaType::QVariant)
returnValue = QVariant(method.returnType(), 0);
New working code:
if (method.returnType() != QMetaType::QVariant)
returnValue = QVariant(method.returnType(), 0);
QGenericReturnArgument returnArgument( method.typeName(), returnValue.data() );