diff options
-rw-r--r-- | src/declarative/qml/qmlcompiler.cpp | 49 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompiler_p.h | 5 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompositetypemanager.cpp | 2 | ||||
-rw-r--r-- | tests/auto/declarative/qmlparser/failingComponent.errors.txt | 4 | ||||
-rw-r--r-- | tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt | 2 | ||||
-rw-r--r-- | tests/auto/declarative/qmlparser/tst_qmlparser.cpp | 8 |
6 files changed, 40 insertions, 30 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 5f92721..a247f8b 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -154,28 +154,18 @@ int QmlCompiledData::indexForLocation(const QmlParser::LocationSpan &l) } QmlCompiler::QmlCompiler() -: exceptionLine(-1), exceptionColumn(-1), output(0) +: output(0) { } bool QmlCompiler::isError() const { - return exceptionLine != -1; + return !exceptions.isEmpty(); } QList<QmlError> QmlCompiler::errors() const { - QList<QmlError> rv; - - if(isError()) { - QmlError error; - error.setDescription(exceptionDescription); - error.setLine(exceptionLine); - error.setColumn(exceptionColumn); - rv << error; - } - - return rv; + return exceptions; } bool QmlCompiler::isValidId(const QString &val) @@ -436,21 +426,29 @@ void QmlCompiler::reset(QmlCompiledComponent *cc, bool deleteMemory) #define COMPILE_EXCEPTION2(token, desc) \ { \ - exceptionLine = token->location.start.line; \ - exceptionColumn = token->location.start.column; \ + QString exceptionDescription; \ + QmlError error; \ + error.setUrl(output->url); \ + error.setLine(token->location.start.line); \ + error.setColumn(token->location.start.column); \ QDebug d(&exceptionDescription); \ d << desc; \ - exceptionDescription = exceptionDescription.trimmed(); \ + error.setDescription(exceptionDescription.trimmed()); \ + exceptions << error; \ return false; \ } #define COMPILE_EXCEPTION(desc) \ { \ - exceptionLine = obj->location.start.line; \ - exceptionColumn = obj->location.start.column; \ + QString exceptionDescription; \ + QmlError error; \ + error.setUrl(output->url); \ + error.setLine(obj->location.start.line); \ + error.setColumn(obj->location.start.column); \ QDebug d(&exceptionDescription); \ d << desc; \ - exceptionDescription = exceptionDescription.trimmed(); \ + error.setDescription(exceptionDescription.trimmed()); \ + exceptions << error; \ return false; \ } @@ -466,7 +464,7 @@ bool QmlCompiler::compile(QmlEngine *engine, #ifdef Q_ENABLE_PERFORMANCE_LOG QFxPerfTimer<QFxPerf::Compile> pc; #endif - exceptionLine = -1; + exceptions.clear(); Q_ASSERT(out); reset(out, true); @@ -481,6 +479,17 @@ bool QmlCompiler::compile(QmlEngine *engine, ref.type = tref.type; else if (tref.unit) { ref.component = tref.unit->toComponent(engine); + + if (ref.component->isError()) { + QmlError error; + error.setUrl(output->url); + error.setDescription(QLatin1String("Unable to create type ") + + unit->data.types().at(ii)); + exceptions << error; + exceptions << ref.component->errors(); + reset(out, true); + return false; + } ref.ref = tref.unit; ref.ref->addref(); } diff --git a/src/declarative/qml/qmlcompiler_p.h b/src/declarative/qml/qmlcompiler_p.h index bc04cfa..5ada98a 100644 --- a/src/declarative/qml/qmlcompiler_p.h +++ b/src/declarative/qml/qmlcompiler_p.h @@ -170,9 +170,8 @@ private: int optimizeExpressions(int start, int end, int patch = -1); QSet<QString> ids; - qint64 exceptionLine; - qint64 exceptionColumn; - QString exceptionDescription; + + QList<QmlError> exceptions; QmlCompiledData *output; }; diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp index 0da1a92..a5e302c 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -86,6 +86,8 @@ QmlComponent *QmlCompositeTypeData::toComponent(QmlEngine *engine) component = new QmlComponent(engine, cc, -1, -1, 0); } else { component = new QmlComponent(engine, 0); + component->d_func()->url = QUrl(url); + component->d_func()->errors = errors; } } diff --git a/tests/auto/declarative/qmlparser/failingComponent.errors.txt b/tests/auto/declarative/qmlparser/failingComponent.errors.txt index 0db1271..12fb4e7 100644 --- a/tests/auto/declarative/qmlparser/failingComponent.errors.txt +++ b/tests/auto/declarative/qmlparser/failingComponent.errors.txt @@ -1,2 +1,2 @@ -2:-1:Unknown property "a" -2:-1:Unable to create object of type "FailingComponent" +-1:-1:Unable to create type FailingComponent +2:5:Cannot assign value to non-existant property "a" diff --git a/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt b/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt index 6c42157..a94b38e 100644 --- a/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt +++ b/tests/auto/declarative/qmlparser/fakeDotProperty.errors.txt @@ -1 +1 @@ -2:-1:Cannot set properties on value as it is of unknown type +2:11:Cannot assign value to non-existant property "something" diff --git a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp index 91433ba..0852d35 100644 --- a/tests/auto/declarative/qmlparser/tst_qmlparser.cpp +++ b/tests/auto/declarative/qmlparser/tst_qmlparser.cpp @@ -70,8 +70,8 @@ private: error.description().toUtf8(); \ actual << errorStr; \ } \ - if (qgetenv("DEBUG") != "") \ - qWarning() << expected << actual; \ + if (qgetenv("DEBUG") != "" && expected != actual) \ + qWarning() << "Expected:" << expected << "Actual:" << actual; \ QCOMPARE(expected, actual); \ } @@ -129,12 +129,12 @@ void tst_qmlparser::errors_data() QTest::newRow("unsupportedProperty") << "unsupportedProperty.txt" << "unsupportedProperty.errors.txt" << false; QTest::newRow("nullDotProperty") << "nullDotProperty.txt" << "nullDotProperty.errors.txt" << true; - QTest::newRow("fakeDotProperty") << "fakeDotProperty.txt" << "fakeDotProperty.errors.txt" << true; + QTest::newRow("fakeDotProperty") << "fakeDotProperty.txt" << "fakeDotProperty.errors.txt" << false; QTest::newRow("duplicateIDs") << "duplicateIDs.txt" << "duplicateIDs.errors.txt" << false; QTest::newRow("unregisteredObject") << "unregisteredObject.txt" << "unregisteredObject.errors.txt" << false; QTest::newRow("empty") << "empty.txt" << "empty.errors.txt" << false; QTest::newRow("missingObject") << "missingObject.txt" << "missingObject.errors.txt" << false; - QTest::newRow("failingComponent") << "failingComponent.txt" << "failingComponent.errors.txt" << true; + QTest::newRow("failingComponent") << "failingComponent.txt" << "failingComponent.errors.txt" << false; QTest::newRow("missingSignal") << "missingSignal.txt" << "missingSignal.errors.txt" << false; } |