From 35debbda13cf5488cd5f94edacfa54017536af61 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 18 Oct 2023 15:27:50 +0200 Subject: QML: Fix further return type constructions There, too, the return type is already initialized and needs to be copied or moved rather than placement new'd. Amends commit 1d8859ce3a3d161ffa2ccd74f195b276795a5af5. Change-Id: I5008659171962a3bd476a6e890e7576579646ae3 Reviewed-by: Semih Yavuz Reviewed-by: Fabian Kosmale Reviewed-by: Sami Shalayel Reviewed-by: Qt CI Bot --- src/qml/jsruntime/qv4jscall_p.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/qml/jsruntime/qv4jscall_p.h') 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()) { - new (result) QVariant(ExecutionEngine::toVariant(jsResult, QMetaType {})); - } else { - resultType.construct(result); + if (resultType == QMetaType::fromType()) + *static_cast(result) = ExecutionEngine::toVariant(jsResult, QMetaType {}); + else ExecutionEngine::metaTypeFromJS(jsResult, resultType, result); - } } return !jsResult->isUndefined(); } -- cgit v1.2.3