aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4jscall_p.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2023-10-18 15:27:50 +0200
committerUlf Hermann <ulf.hermann@qt.io>2023-10-20 11:40:16 +0200
commit35debbda13cf5488cd5f94edacfa54017536af61 (patch)
tree0aa48c6b47de98c1174911324f24453be58ad33c /src/qml/jsruntime/qv4jscall_p.h
parent4f538c1feb657b5d48bb9f92994312f94933e395 (diff)
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 <semih.yavuz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/qml/jsruntime/qv4jscall_p.h')
-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();
}