diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-05-06 01:22:52 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2009-05-06 01:22:52 (GMT) |
commit | 2ae61bfcbb3f93904ecc3c1241a1743c44f0f555 (patch) | |
tree | 8c0afefdfcd41ef13148266f89efb7a8d1b65b98 /src/declarative/qml | |
parent | 547223a4f31067ed34acabd9a2d8a0b7645fd3f8 (diff) | |
download | Qt-2ae61bfcbb3f93904ecc3c1241a1743c44f0f555.zip Qt-2ae61bfcbb3f93904ecc3c1241a1743c44f0f555.tar.gz Qt-2ae61bfcbb3f93904ecc3c1241a1743c44f0f555.tar.bz2 |
Improve error handling
If a sub-component causes an error during creation we propagate those errors to the instantiating component.
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qmlerror.cpp | 37 | ||||
-rw-r--r-- | src/declarative/qml/qmlvme.cpp | 7 | ||||
-rw-r--r-- | src/declarative/qml/qmlvme_p.h | 2 |
3 files changed, 24 insertions, 22 deletions
diff --git a/src/declarative/qml/qmlerror.cpp b/src/declarative/qml/qmlerror.cpp index 2ed3500..149e173 100644 --- a/src/declarative/qml/qmlerror.cpp +++ b/src/declarative/qml/qmlerror.cpp @@ -188,10 +188,9 @@ QDebug operator<<(QDebug debug, const QmlError &error) output += QLatin1String(": ") + error.description(); - debug << qPrintable(output) << "\n"; + debug << qPrintable(output); - if (error.line() > 0 && error.column() > 0 && - url.scheme() == QLatin1String("file")) { + if (error.line() > 0 && url.scheme() == QLatin1String("file")) { QString file = url.toLocalFile(); QFile f(file); if (f.open(QIODevice::ReadOnly)) { @@ -202,22 +201,24 @@ QDebug operator<<(QDebug debug, const QmlError &error) if (lines.count() >= error.line()) { const QString &line = lines.at(error.line() - 1); - debug << qPrintable(line) << "\n"; - - int column = qMax(0, error.column() - 1); - column = qMin(column, line.length()); - - QByteArray ind; - ind.reserve(column); - for (int i = 0; i < column; ++i) { - const QChar ch = line.at(i); - if (ch.isSpace()) - ind.append(ch.unicode()); - else - ind.append(' '); + debug << "\n " << qPrintable(line); + + if(error.column() > 0) { + int column = qMax(0, error.column() - 1); + column = qMin(column, line.length()); + + QByteArray ind; + ind.reserve(column); + for (int i = 0; i < column; ++i) { + const QChar ch = line.at(i); + if (ch.isSpace()) + ind.append(ch.unicode()); + else + ind.append(' '); + } + ind.append('^'); + debug << "\n " << ind.constData(); } - ind.append('^'); - debug << ind.constData(); } } } diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index ee7a881..82df3bc 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -170,7 +170,6 @@ static inline int qIndexOfProperty(QObject *o, const char *name) } QmlVME::QmlVME() -: exceptionLine(-1) { } @@ -261,8 +260,12 @@ QObject *QmlVME::run(QmlContext *ctxt, QmlCompiledComponent *comp, int start, in QFxCompilerTimer<QFxCompiler::InstrCreateObject> cc; #endif QObject *o = types.at(instr.create.type).createInstance(QmlContext::activeContext()); - if (!o) + if (!o) { + if(types.at(instr.create.type).component) + vmeErrors << types.at(instr.create.type).component->errors(); + VME_EXCEPTION("Unable to create object of type" << types.at(instr.create.type).className); + } if (instr.create.data != -1) { QmlCustomParser *customParser = diff --git a/src/declarative/qml/qmlvme_p.h b/src/declarative/qml/qmlvme_p.h index 86cd040..f7e13d6 100644 --- a/src/declarative/qml/qmlvme_p.h +++ b/src/declarative/qml/qmlvme_p.h @@ -68,8 +68,6 @@ private: QmlInstruction &, QmlCompiledData *); QList<QmlError> vmeErrors; - qint64 exceptionLine; - QString exceptionDescription; }; QT_END_NAMESPACE |