[new compiler] Fix error location when id property is used in list model elements
authorSimon Hausmann <simon.hausmann@digia.com>
Wed, 19 Feb 2014 11:54:02 +0000 (12:54 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Sun, 2 Mar 2014 10:46:09 +0000 (11:46 +0100)
Change-Id: Iec648d593d30117c512009dcc6ab0d50b8fc51af
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/qml/qqmlcustomparser.cpp
src/qml/qml/qqmlcustomparser_p.h
src/qml/types/qqmllistmodel.cpp

index e976000c9ec3aa9ef9da64def696ae69520293b5..fc14fae2753c23bf31914f8ecc9628b6f371ae1e 100644 (file)
@@ -277,29 +277,15 @@ void QQmlCustomParser::error(const QQmlCustomParserNode& node, const QString& de
 }
 
 /*!
-    Reports an error in parsing \a binding, with the given \a description.
-
-    An error is generated referring to the position of \a node in the source file.
-*/
-void QQmlCustomParser::error(const QV4::CompiledData::Binding *binding, const QString &description)
-{
-    QQmlError error;
-    error.setLine(binding->location.line);
-    error.setColumn(binding->location.column);
-    error.setDescription(description);
-    exceptions << error;
-}
-
-/*!
-    Reports an error in parsing \a object, with the given \a description.
+    Reports an error with the given \a description.
 
-    An error is generated referring to the position of \a object in the source file.
+    An error is generated referring to the \a location in the source file.
 */
-void QQmlCustomParser::error(const QV4::CompiledData::Object *object, const QString &description)
+void QQmlCustomParser::error(const CompiledData::Location &location, const QString &description)
 {
     QQmlError error;
-    error.setLine(object->location.line);
-    error.setColumn(object->location.column);
+    error.setLine(location.line);
+    error.setColumn(location.column);
     error.setDescription(description);
     exceptions << error;
 }
index b4067174103f5cf660703c399e1169a354dc81e2..d06a8c1551a0df3b52245af7ce27f2b080b166c2 100644 (file)
@@ -149,8 +149,11 @@ protected:
     void error(const QString& description);
     void error(const QQmlCustomParserProperty&, const QString& description);
     void error(const QQmlCustomParserNode&, const QString& description);
-    void error(const QV4::CompiledData::Binding *binding, const QString& description);
-    void error(const QV4::CompiledData::Object *object, const QString& description);
+    void error(const QV4::CompiledData::Binding *binding, const QString& description)
+    { error(binding->location, description); }
+    void error(const QV4::CompiledData::Object *object, const QString& description)
+    { error(object->location, description); }
+    void error(const QV4::CompiledData::Location &location, const QString& description);
 
     int evaluateEnum(const QByteArray&, bool *ok) const;
 
index 50b7614c3bd7a600328e627464866c3cce17409c..eed76ee09e1281ac3c6149e67f882c4006f8f22d 100644 (file)
@@ -2407,7 +2407,7 @@ bool QQmlListModelParser::compileProperty(const QV4::CompiledData::QmlUnit *qmlU
         }
 
         if (!qmlUnit->header.stringAt(target->idIndex).isEmpty()) {
-            error(binding, QQmlListModel::tr("ListElement: cannot use reserved \"id\" property"));
+            error(target->locationOfIdProperty, QQmlListModel::tr("ListElement: cannot use reserved \"id\" property"));
             return false;
         }