diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-10-19 15:22:25 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-10-20 15:51:23 +0200 |
commit | bf115a446c1a633a11577306eff8a78028a7f5b5 (patch) | |
tree | 8a2cd7650fe9d5ace7bdfdaa31669fccd8f1021a /src/qml/qml/qqmlcomponent.cpp | |
parent | 974e2c668ae6e942f9e5d3eda8d77b1893af371f (diff) |
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 <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlcomponent.cpp')
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
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()); } } |