V4: Deal with AOT-compiled functions returning QVariant

In this case we need to pass a pointer to the return variant itself, not
to its data.

Change-Id: I86e468f106f29e1f1be8adee9882d465fd6da533
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Ulf Hermann 2020-11-17 12:13:55 +01:00
parent 45254660d0
commit ec4fd8832e
1 changed files with 11 additions and 2 deletions

View File

@ -463,8 +463,17 @@ ReturnedValue VME::exec(CppStackFrame *frame, ExecutionEngine *engine)
Scope scope(engine);
Scoped<QmlContext> qmlContext(scope, engine->qmlContext());
QVariant resultVariant(function->aotFunction->returnType, nullptr);
function->aotFunction->functionPtr(qmlContext->qmlContext()->asQQmlContext(), qmlContext->qmlScope(), resultVariant.data());
QVariant resultVariant;
if (function->aotFunction->returnType.id() == QMetaType::QVariant) {
function->aotFunction->functionPtr(
qmlContext->qmlContext()->asQQmlContext(), qmlContext->qmlScope(),
&resultVariant);
} else {
resultVariant = QVariant(function->aotFunction->returnType, nullptr);
function->aotFunction->functionPtr(
qmlContext->qmlContext()->asQQmlContext(), qmlContext->qmlScope(),
resultVariant.data());
}
result = engine->fromVariant(resultVariant);
} else {
// interpreter