diff options
author | Simon Hausmann <simon.hausmann@digia.com> | 2013-12-10 15:25:22 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-12-10 15:46:09 +0100 |
commit | 29b6d2e45c7434fccf2e6878630e62d5dcce38db (patch) | |
tree | d2d0ad7639c9863c00cdd8558d9663bea813c3f3 /src/qml/compiler/qqmlcodegenerator_p.h | |
parent | fb72bb3cf27d1f94760709aaab82e3524ae936f4 (diff) |
Fix broken Maroon game / regression in PropertyChanges {} element
Commit 0aadcf8077840068eb182269e9ed9c31ad12f45e that pre-compiles the
expressions in PropertyChanges {} introduced a regression in where the
evaluation context was incorrect and thus bindings would not be able to
access the correct properties. For example
PropertyChanges {
target: someObject
y: height / 2
}
Here height should be looked up in the context of "someObject", not of the
PropertyChanges element.
This patch introduces an auto-test that verifies that the lookup context is
correct and fixes the bug by disabling accelerated compile time property
lookups for binding expressions that are requested from a custom parser.
Change-Id: I5cb607d07211b453ddfc9928ccbf5f9ecec85575
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/compiler/qqmlcodegenerator_p.h')
-rw-r--r-- | src/qml/compiler/qqmlcodegenerator_p.h | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/src/qml/compiler/qqmlcodegenerator_p.h b/src/qml/compiler/qqmlcodegenerator_p.h index 348ef0a2cf..0a0e4f2d5b 100644 --- a/src/qml/compiler/qqmlcodegenerator_p.h +++ b/src/qml/compiler/qqmlcodegenerator_p.h @@ -166,6 +166,20 @@ struct Pragma QV4::CompiledData::Location location; }; +struct CompiledFunctionOrExpression +{ + CompiledFunctionOrExpression() + : disableAcceleratedLookups(false) + {} + CompiledFunctionOrExpression(AST::Node *n) + : node(n) + , disableAcceleratedLookups(false) + {} + AST::Node *node; // FunctionDeclaration, Statement or Expression + QString name; + bool disableAcceleratedLookups; +}; + struct ParsedQML { ParsedQML(bool debugMode) @@ -180,7 +194,7 @@ struct ParsedQML AST::UiProgram *program; int indexOfRootObject; QList<QmlObject*> objects; - QList<AST::Node*> functions; // FunctionDeclaration, Statement or Expression + QList<CompiledFunctionOrExpression> functions; QV4::Compiler::JSUnitGenerator jsGenerator; QV4::CompiledData::TypeReferenceMap typeReferences; @@ -269,7 +283,7 @@ public: QList<QV4::CompiledData::Import*> _imports; QList<Pragma*> _pragmas; QList<QmlObject*> _objects; - QList<AST::Node*> _functions; + QList<CompiledFunctionOrExpression> _functions; QV4::CompiledData::TypeReferenceMap _typeReferences; @@ -362,7 +376,7 @@ struct Q_QML_EXPORT JSCodeGen : public QQmlJS::Codegen void beginObjectScope(QQmlPropertyCache *scopeObject); // Returns mapping from input functions to index in V4IR::Module::functions / compiledData->runtimeFunctions - QVector<int> generateJSCodeForFunctionsAndBindings(const QList<AST::Node*> &functions, const QHash<int, QString> &functionNames); + QVector<int> generateJSCodeForFunctionsAndBindings(const QList<CompiledFunctionOrExpression> &functions); protected: virtual void beginFunctionBodyHook(); @@ -376,6 +390,7 @@ private: AST::UiProgram *qmlRoot; QQmlTypeNameCache *imports; + bool _disableAcceleratedLookups; ObjectIdMapping _idObjects; QQmlPropertyCache *_contextObject; QQmlPropertyCache *_scopeObject; |