diff options
Diffstat (limited to 'tools/qmltc/qmltccompiler.cpp')
-rw-r--r-- | tools/qmltc/qmltccompiler.cpp | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/tools/qmltc/qmltccompiler.cpp b/tools/qmltc/qmltccompiler.cpp index 9a38cca06c..31140e5281 100644 --- a/tools/qmltc/qmltccompiler.cpp +++ b/tools/qmltc/qmltccompiler.cpp @@ -188,6 +188,7 @@ void QmltcCompiler::compileType( current.init.access = QQmlJSMetaMethod::Protected; current.beginClass.access = QQmlJSMetaMethod::Protected; current.endInit.access = QQmlJSMetaMethod::Protected; + current.setComplexBindings.access = QQmlJSMetaMethod::Protected; current.completeComponent.access = QQmlJSMetaMethod::Protected; current.finalizeComponent.access = QQmlJSMetaMethod::Protected; current.handleOnCompleted.access = QQmlJSMetaMethod::Protected; @@ -200,6 +201,8 @@ void QmltcCompiler::compileType( current.beginClass.returnType = u"void"_s; current.endInit.name = u"QML_endInit"_s; current.endInit.returnType = u"void"_s; + current.setComplexBindings.name = u"QML_setComplexBindings"_s; + current.setComplexBindings.returnType = u"void"_s; current.completeComponent.name = u"QML_completeComponent"_s; current.completeComponent.returnType = u"void"_s; current.finalizeComponent.name = u"QML_finalizeComponent"_s; @@ -217,6 +220,7 @@ void QmltcCompiler::compileType( current.init.parameterList = { creator, engine, ctxtdata, finalizeFlag }; current.beginClass.parameterList = { creator, finalizeFlag }; current.endInit.parameterList = { creator, engine, finalizeFlag }; + current.setComplexBindings.parameterList = { creator, engine, finalizeFlag }; current.completeComponent.parameterList = { creator, finalizeFlag }; current.finalizeComponent.parameterList = { creator, finalizeFlag }; current.handleOnCompleted.parameterList = { creator, finalizeFlag }; @@ -225,6 +229,7 @@ void QmltcCompiler::compileType( current.init.parameterList = { creator, engine, ctxtdata }; current.beginClass.parameterList = { creator }; current.endInit.parameterList = { creator, engine }; + current.setComplexBindings.parameterList = { creator, engine }; current.completeComponent.parameterList = { creator }; current.finalizeComponent.parameterList = { creator }; current.handleOnCompleted.parameterList = { creator }; @@ -266,6 +271,7 @@ void QmltcCompiler::compileType( auto postponedQmlContextSetup = generator.generate_initCode(current, type); generator.generate_endInitCode(current, type); + generator.generate_setComplexBindingsCode(current, type); generator.generate_beginClassCode(current, type); generator.generate_completeComponentCode(current, type); generator.generate_finalizeComponentCode(current, type); @@ -281,9 +287,8 @@ static Iterator partitionBindings(Iterator first, Iterator last) // later point, so we should sort or partition the range. we do a stable // partition since the relative order of binding evaluation affects the UI return std::stable_partition(first, last, [](const QQmlJSMetaPropertyBinding &b) { - // we want script bindings to be at the end, so do the negation of "is - // script binding" - return b.bindingType() != QQmlJSMetaPropertyBinding::Script; + // we want complex bindings to be at the end, so do the negation + return !QmltcCompiler::isComplexBinding(b); }); } @@ -1227,10 +1232,10 @@ void QmltcCompiler::compileScriptBinding(QmltcType ¤t, slotMethod.type = QQmlJSMetaMethod::Slot; current.functions << std::move(slotMethod); - current.endInit.body << u"QObject::connect(" + This_signal + u", " - + QmltcCodeGenerator::wrap_qOverload(slotParameters, - u"&" + objectClassName_signal + u"::" - + signalName) + current.setComplexBindings.body + << u"QObject::connect(" + This_signal + u", " + + QmltcCodeGenerator::wrap_qOverload( + slotParameters, u"&" + objectClassName_signal + u"::" + signalName) + u", " + This_slot + u", &" + objectClassName_slot + u"::" + slotName + u");"; }; @@ -1269,7 +1274,7 @@ void QmltcCompiler::compileScriptBinding(QmltcType ¤t, } QmltcCodeGenerator::generate_createBindingOnProperty( - ¤t.endInit.body, generate_callCompilationUnit(m_urlMethodName), + ¤t.setComplexBindings.body, generate_callCompilationUnit(m_urlMethodName), u"this"_s, // NB: always using enclosing object as a scope for the binding static_cast<qsizetype>(objectType->ownRuntimeFunctionIndex(binding.scriptIndex())), bindingTarget, // binding target @@ -1314,7 +1319,7 @@ void QmltcCompiler::compileScriptBinding(QmltcType ¤t, // TODO: this could be dropped if QQmlEngine::setContextForObject() is // done before currently generated C++ object is constructed - current.endInit.body << bindingSymbolName + u".reset(new QPropertyChangeHandler<" + current.setComplexBindings.body << bindingSymbolName + u".reset(new QPropertyChangeHandler<" + bindingFunctorName + u">(" + QmltcCodeGenerator::wrap_privateClass(accessor.name, *actualProperty) + u"->" + bindableString + u"().onValueChanged(" + bindingFunctorName + u"(" |