aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/qml/jsruntime/qv4jscall_p.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/qml/jsruntime/qv4jscall_p.h b/src/qml/jsruntime/qv4jscall_p.h
index 06a8e62761..b76ae7d52f 100644
--- a/src/qml/jsruntime/qv4jscall_p.h
+++ b/src/qml/jsruntime/qv4jscall_p.h
@@ -196,16 +196,15 @@ bool convertAndCall(ExecutionEngine *engine, QObject *thisObject,
const QMetaType resultType = types[0];
if (scope.hasException()) {
// Clear the return value
+ resultType.destruct(result);
resultType.construct(result);
} else {
// When the return type is QVariant, JS objects are to be returned as
// QJSValue wrapped in QVariant. metaTypeFromJS unwraps them, unfortunately.
- if (resultType == QMetaType::fromType<QVariant>()) {
- new (result) QVariant(ExecutionEngine::toVariant(jsResult, QMetaType {}));
- } else {
- resultType.construct(result);
+ if (resultType == QMetaType::fromType<QVariant>())
+ *static_cast<QVariant *>(result) = ExecutionEngine::toVariant(jsResult, QMetaType {});
+ else
ExecutionEngine::metaTypeFromJS(jsResult, resultType, result);
- }
}
return !jsResult->isUndefined();
}