From b1f55d5a6a23f3dd6b02691ee4d0ddf68cc119b4 Mon Sep 17 00:00:00 2001 From: Miikka Heikkinen Date: Thu, 20 Apr 2023 15:06:16 +0300 Subject: [PATCH] Fix binding assignment failing sometimes Change-Id: Ic94cc911411d3162cd840feba86a445a4bc76c8e Reviewed-by: Qt CI Bot Reviewed-by: Thomas Hartmann --- .../qml2puppet/instances/objectnodeinstance.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/tools/qml2puppet/qml2puppet/instances/objectnodeinstance.cpp b/src/tools/qml2puppet/qml2puppet/instances/objectnodeinstance.cpp index fc171c87723..8a982f5cdd5 100644 --- a/src/tools/qml2puppet/qml2puppet/instances/objectnodeinstance.cpp +++ b/src/tools/qml2puppet/qml2puppet/instances/objectnodeinstance.cpp @@ -507,6 +507,17 @@ void ObjectNodeInstance::setPropertyBinding(const PropertyName &name, const QStr bool qmlExpressionHasError = false; + QStringList idlist; + for (const auto &instance : nodeInstanceServer()->nodeInstances()) + idlist.append(instance.id()); + + // Always set ids using the root context, since they are defined there anyway + if (idlist.contains(expression)) { + QmlPrivateGate::setPropertyBinding(object(), + context()->engine()->rootContext(), name, expression); + return; + } + if (!isPropertyChange()) { QQmlExpression qmlExpression(context(), object(), expression); qmlExpression.evaluate();