aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-02-10 21:15:41 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-18 10:01:48 +0100
commit3c0bf1c0a8fe80f75f9e9194637c86726d156c82 (patch)
tree7a4ce1ab2cf8d44d960168f4ee25287024c000c0
parenta65b8785621ebf58f34eb0c1759376fc0a1117c7 (diff)
[new compiler] Fix error reporting null object group property access
The new code path reported line and column, the latter was missing from the old code path and is easily added. Change-Id: I730e56f0fe4e99091dfb10e5f601faf1d3b8949c Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
-rw-r--r--src/qml/qml/qqmlcompiler.cpp1
-rw-r--r--src/qml/qml/qqmlinstruction_p.h1
-rw-r--r--src/qml/qml/qqmlvme.cpp13
-rw-r--r--tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.errors.txt2
-rw-r--r--tests/auto/qml/qqmllanguage/data/nullDotProperty.errors.txt2
5 files changed, 16 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp
index 9262e2a119..c71c7432a8 100644
--- a/src/qml/qml/qqmlcompiler.cpp
+++ b/src/qml/qml/qqmlcompiler.cpp
@@ -1379,6 +1379,7 @@ void QQmlCompiler::genObjectBody(QQmlScript::Object *obj)
Instruction::FetchObject fetch;
fetch.property = prop->index;
fetch.line = prop->location.start.line;
+ fetch.column = prop->location.start.column;
output->addInstruction(fetch);
if (!prop->value->synthdata.isEmpty()) {
diff --git a/src/qml/qml/qqmlinstruction_p.h b/src/qml/qml/qqmlinstruction_p.h
index d76c9f9f64..314debc8ee 100644
--- a/src/qml/qml/qqmlinstruction_p.h
+++ b/src/qml/qml/qqmlinstruction_p.h
@@ -253,6 +253,7 @@ union QQmlInstruction
QML_INSTR_HEADER
int property;
ushort line;
+ ushort column;
};
struct instr_fetchValue {
QML_INSTR_HEADER
diff --git a/src/qml/qml/qqmlvme.cpp b/src/qml/qml/qqmlvme.cpp
index e60010ade8..ce4997fef9 100644
--- a/src/qml/qml/qqmlvme.cpp
+++ b/src/qml/qml/qqmlvme.cpp
@@ -92,6 +92,17 @@ using namespace QQmlVMETypes;
goto exceptionExit; \
}
+#define VME_EXCEPTION_WITH_COLUMN(desc, line, column) \
+ { \
+ QQmlError error; \
+ error.setDescription(desc.trimmed()); \
+ error.setLine(line); \
+ error.setColumn(column); \
+ error.setUrl(COMP->url); \
+ *errors << error; \
+ goto exceptionExit; \
+ }
+
bool QQmlVME::s_enableComponentComplete = true;
void QQmlVME::init(QQmlContextData *ctxt, QQmlCompiledData *comp, int start,
@@ -992,7 +1003,7 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
instr.property, a);
if (!obj)
- VME_EXCEPTION(tr("Cannot set properties on %1 as it is null").arg(QString::fromUtf8(target->metaObject()->property(instr.property).name())), instr.line);
+ VME_EXCEPTION_WITH_COLUMN(tr("Cannot set properties on %1 as it is null").arg(QString::fromUtf8(target->metaObject()->property(instr.property).name())), instr.line, instr.column);
objects.push(obj);
qmlBindingWrappers[objects.count() - 1] = QV4::Primitive::undefinedValue();
diff --git a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.errors.txt b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.errors.txt
index 4a7e3830a8..0f42a4b39d 100644
--- a/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/invalidGroupedProperty.7.errors.txt
@@ -1 +1 @@
-4:-1:Cannot set properties on nullGrouped as it is null
+4:5:Cannot set properties on nullGrouped as it is null
diff --git a/tests/auto/qml/qqmllanguage/data/nullDotProperty.errors.txt b/tests/auto/qml/qqmllanguage/data/nullDotProperty.errors.txt
index 07a40949cd..581d34e0c3 100644
--- a/tests/auto/qml/qqmllanguage/data/nullDotProperty.errors.txt
+++ b/tests/auto/qml/qqmllanguage/data/nullDotProperty.errors.txt
@@ -1 +1 @@
-3:-1:Cannot set properties on obj as it is null
+3:5:Cannot set properties on obj as it is null