Fix binding assignment failing sometimes

Change-Id: Ic94cc911411d3162cd840feba86a445a4bc76c8e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Miikka Heikkinen
2023-04-20 15:06:16 +03:00
parent ece03f55ac
commit b1f55d5a6a

View File

@@ -507,6 +507,17 @@ void ObjectNodeInstance::setPropertyBinding(const PropertyName &name, const QStr
bool qmlExpressionHasError = false; 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()) { if (!isPropertyChange()) {
QQmlExpression qmlExpression(context(), object(), expression); QQmlExpression qmlExpression(context(), object(), expression);
qmlExpression.evaluate(); qmlExpression.evaluate();