From bf115a446c1a633a11577306eff8a78028a7f5b5 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 19 Oct 2021 15:22:25 +0200 Subject: Improve type conversions from/to QJSValue We can convert everything into a QJSValue if we have an engine and we can save a binding function in a QVariant by wrapping it into QJSValue. Change-Id: I48e7c13f3f744f1c50bf673b427fe9331250f313 Reviewed-by: Andrei Golubev Reviewed-by: Fabian Kosmale --- src/qml/qml/qqmlcomponent.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/qml/qml/qqmlcomponent.cpp') diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 5a814b16c5..e81834ef1a 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -376,7 +376,8 @@ QObject *QQmlComponentPrivate::doBeginCreate(QQmlComponent *q, QQmlContext *cont bool QQmlComponentPrivate::setInitialProperty(QObject *component, const QString& name, const QVariant &value) { - QQmlProperty prop = QQmlComponentPrivate::removePropertyFromRequired(component, name, requiredProperties()); + QQmlProperty prop = QQmlComponentPrivate::removePropertyFromRequired( + component, name, requiredProperties(), engine); QQmlPropertyPrivate *privProp = QQmlPropertyPrivate::get(prop); const bool isValid = prop.isValid(); if (!isValid || !privProp->writeValueProperty(value, {})) { @@ -1037,9 +1038,11 @@ void QQmlComponentPrivate::complete(QQmlEnginePrivate *enginePriv, ConstructionS * classes which create components should not need it and should only need to call * setInitialProperties. */ -QQmlProperty QQmlComponentPrivate::removePropertyFromRequired(QObject *createdComponent, const QString &name, RequiredProperties &requiredProperties, bool* wasInRequiredProperties) +QQmlProperty QQmlComponentPrivate::removePropertyFromRequired( + QObject *createdComponent, const QString &name, RequiredProperties &requiredProperties, + QQmlEngine *engine, bool *wasInRequiredProperties) { - QQmlProperty prop(createdComponent, name); + QQmlProperty prop(createdComponent, name, engine); auto privProp = QQmlPropertyPrivate::get(prop); if (prop.isValid()) { // resolve outstanding required properties @@ -1418,7 +1421,8 @@ void QQmlComponentPrivate::setInitialProperties(QV4::ExecutionEngine *engine, QV qmlWarning(createdComponent, engine->catchExceptionAsQmlError()); continue; } else if (isTopLevelProperty) { - auto prop = removePropertyFromRequired(createdComponent, name->toQString(), requiredProperties); + auto prop = removePropertyFromRequired(createdComponent, name->toQString(), + requiredProperties, engine->qmlEngine()); } } -- cgit v1.2.3