diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-01-13 10:16:05 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-16 00:03:05 +0100 |
commit | 74c390d44f133f327fc02b9561fe43a23ff4d3b3 (patch) | |
tree | 16ca7754125292008a9f68c6249ed56e307f88d3 /src | |
parent | ef1860e8c47a5816b151e5d63dbc0db196f9d0a8 (diff) |
lower case QML components are accepted when used with 'as' import
If an Object Binding is in a namespace, ensure that the Component name
begins with a capital letter.
Task-number:QTBUG-20786
Change-Id: Id4a0c0fdb0c9b9516bea597a4994bb7519339bc9
Reviewed-by: Roberto Raggi <roberto.raggi@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/qml/qdeclarativescript.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/declarative/qml/qdeclarativescript.cpp b/src/declarative/qml/qdeclarativescript.cpp index cbb2bc2cac..660fa95de2 100644 --- a/src/declarative/qml/qdeclarativescript.cpp +++ b/src/declarative/qml/qdeclarativescript.cpp @@ -679,9 +679,9 @@ ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName, AST::UiObjectInitializer *initializer) { int lastTypeDot = objectType.lastIndexOf(QLatin1Char('.')); - bool isType = !objectType.isEmpty() && - (objectType.at(0).isUpper() || - (lastTypeDot >= 0 && objectType.at(lastTypeDot+1).isUpper())); + + // With no preceding qualification, first char is at (-1 + 1) == 0 + bool isType = !objectType.isEmpty() && objectType.at(lastTypeDot+1).isUpper(); int propertyCount = 0; for (AST::UiQualifiedId *name = propertyName; name; name = name->next){ @@ -701,11 +701,26 @@ ProcessAST::defineObjectBinding(AST::UiQualifiedId *propertyName, if (!isType) { - if(propertyCount || !currentObject()) { + // Is the identifier qualified by a namespace? + int namespaceLength = 0; + if (lastTypeDot > 0) { + const QString qualifier(objectType.left(lastTypeDot)); + + for (int ii = 0; ii < _parser->_imports.count(); ++ii) { + const QDeclarativeScript::Import &import = _parser->_imports.at(ii); + if (import.qualifier == qualifier) { + // The qualifier is a namespace - expect a type here + namespaceLength = qualifier.length() + 1; + break; + } + } + } + + if (propertyCount || !currentObject() || namespaceLength) { QDeclarativeError error; error.setDescription(QCoreApplication::translate("QDeclarativeParser","Expected type name")); error.setLine(typeLocation.startLine); - error.setColumn(typeLocation.startColumn); + error.setColumn(typeLocation.startColumn + namespaceLength); _parser->_errors << error; return 0; } |