diff options
Diffstat (limited to 'tools/qmltc/qmltccompilerpieces.cpp')
-rw-r--r-- | tools/qmltc/qmltccompilerpieces.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/tools/qmltc/qmltccompilerpieces.cpp b/tools/qmltc/qmltccompilerpieces.cpp index 601cf1bbed..cd1735bc07 100644 --- a/tools/qmltc/qmltccompilerpieces.cpp +++ b/tools/qmltc/qmltccompilerpieces.cpp @@ -15,8 +15,8 @@ static QString scopeName(const QQmlJSScope::ConstPtr &scope) { Q_ASSERT(scope->isFullyResolved()); const auto scopeType = scope->scopeType(); - if (scopeType == QQmlJSScope::GroupedPropertyScope - || scopeType == QQmlJSScope::AttachedPropertyScope) { + if (scopeType == QQmlSA::ScopeType::GroupedPropertyScope + || scopeType == QQmlSA::ScopeType::AttachedPropertyScope) { return scope->baseType()->internalName(); } return scope->internalName(); @@ -237,15 +237,18 @@ void QmltcCodeGenerator::generate_createBindingOnProperty( } *block += prologue; - *block << value + u"->" + bindable + u"().setBinding(" + createBindingForBindable + u");"; + *block << u"if (!initializedCache.contains(\"%1\"))"_s.arg(p.propertyName()); + *block << u" "_s + value + u"->" + bindable + u"().setBinding(" + createBindingForBindable + u");"; *block += epilogue; } else { QString createBindingForNonBindable = - u"QT_PREPEND_NAMESPACE(QQmlCppBinding)::createBindingForNonBindable(" + unitVarName + u" "_s + + u"QT_PREPEND_NAMESPACE(QQmlCppBinding)::createBindingForNonBindable(" + unitVarName + u", " + scope + u", " + QString::number(functionIndex) + u", " + target + u", " + QString::number(propertyIndex) + u", " + QString::number(valueTypeIndex) + u", " + propName + u")"; // Note: in this version, the binding is set implicitly + *block << u"if (!initializedCache.contains(\"%1\"))"_s.arg(p.propertyName()); *block << createBindingForNonBindable + u";"; } } @@ -293,8 +296,8 @@ void QmltcCodeGenerator::generate_createTranslationBindingOnProperty( QmltcCodeGenerator::PreparedValue QmltcCodeGenerator::wrap_mismatchingTypeConversion(const QQmlJSMetaProperty &p, QString value) { - auto isDerivedFromBuiltin = [](QQmlJSScope::ConstPtr t, const QString &builtin) { - for (; t; t = t->baseType()) { + auto isDerivedFromBuiltin = [](const QQmlJSScope::ConstPtr &derived, const QString &builtin) { + for (QQmlJSScope::ConstPtr t = derived; t; t = t->baseType()) { if (t->internalName() == builtin) return true; } @@ -302,7 +305,7 @@ QmltcCodeGenerator::wrap_mismatchingTypeConversion(const QQmlJSMetaProperty &p, }; QStringList prologue; QStringList epilogue; - auto propType = p.type(); + const QQmlJSScope::ConstPtr propType = p.type(); if (isDerivedFromBuiltin(propType, u"QVariant"_s)) { const QString variantName = u"var_" + p.propertyName(); prologue << u"{ // accepts QVariant"_s; |