From ecf6a2a3658fa17cd4c34f1dd5acc1904f8b4314 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 21 Sep 2017 16:29:39 -0500 Subject: Allow assigning functions in ListElement As an alternative to using eval with a string. This allows code such as: // model ListElement { action: function() { doSomething() } } // delegate MouseArea { onClicked: model.action() } [ChangeLog][ListModel] Support assignment of function declarations in ListElement, to allow for models with actions. Change-Id: I50d188ab30f43b2b8a47f48ceb4281d3ca55bd44 Reviewed-by: Simon Hausmann --- src/qml/compiler/qqmlirbuilder.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/qml/compiler/qqmlirbuilder.cpp') diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 57121e5460..02ff8947c4 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -1067,6 +1067,8 @@ void IRBuilder::setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST } else if (QQmlJS::AST::NumericLiteral *lit = QQmlJS::AST::cast(expr)) { binding->type = QV4::CompiledData::Binding::Type_Number; binding->setNumberValueInternal(lit->value); + } else if (QQmlJS::AST::cast(expr)) { + binding->flags |= QV4::CompiledData::Binding::IsFunctionExpression; } else { if (QQmlJS::AST::UnaryMinusExpression *unaryMinus = QQmlJS::AST::cast(expr)) { -- cgit v1.2.3