diff options
author | Mark Visser <mjmvisser@gmail.com> | 2013-04-30 14:12:37 -0400 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-05-08 10:46:13 +0200 |
commit | 13afb2b49daec9f5f65dc9a99151c91d685dce13 (patch) | |
tree | 79c00dec10a6d90152213c0a85fafe6a9a480a95 /src/qml/qml/qqmlerror.cpp | |
parent | 22fc92cf9187460785a05e31620823fe8afe5eab (diff) |
QQmlError.object now holds the scope object that caused exceptions.
Exception errors sent via QQmlEngine::warnings lacked a pointer to the
containing scope. I added an object property to QQmlError, and the
necessary code to fill it with the QObject* scope from binding exception
callbacks.
Task-number: QTBUG-30930
Change-Id: I2a987e8cefc3a2a474d338893e9ebcb77c167adf
Reviewed-by: Kai Koehne <kai.koehne@digia.com>
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'src/qml/qml/qqmlerror.cpp')
-rw-r--r-- | src/qml/qml/qqmlerror.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/src/qml/qml/qqmlerror.cpp b/src/qml/qml/qqmlerror.cpp index 98d8259dda..0c8e46bd8d 100644 --- a/src/qml/qml/qqmlerror.cpp +++ b/src/qml/qml/qqmlerror.cpp @@ -84,10 +84,11 @@ public: QString description; quint16 line; quint16 column; + QObject *object; }; QQmlErrorPrivate::QQmlErrorPrivate() -: line(0), column(0) +: line(0), column(0), object() { } @@ -122,6 +123,7 @@ QQmlError &QQmlError::operator=(const QQmlError &other) d->description = other.d->description; d->line = other.d->line; d->column = other.d->column; + d->object = other.d->object; } return *this; } @@ -215,6 +217,27 @@ void QQmlError::setColumn(int column) } /*! + Returns the nearest object where this error occurred. + Exceptions in bound property expressions set this to the object + to which the property belongs. It will be 0 for all + other exceptions. + */ +QObject *QQmlError::object() const +{ + if (d) return d->object; + else return 0; +} + +/*! + Sets the nearest \a object where this error occurred. + */ +void QQmlError::setObject(QObject *object) +{ + if (!d) d = new QQmlErrorPrivate; + d->object = object; +} + +/*! Returns the error as a human readable string. */ QString QQmlError::toString() const |