diff options
author | Lars Knoll <lars.knoll@digia.com> | 2013-05-20 20:27:16 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@digia.com> | 2013-05-21 10:05:22 +0200 |
commit | b7d79a0c271c9541c96be4028ee76eb304e06bf5 (patch) | |
tree | 5931c074dc6537e874bc87f9b60151a52390367d /src/qml/qml | |
parent | d0d9e6458f1ce90ca4985d7cf03e7bfae48d664a (diff) |
Cleanup QQmlDelayedError
Remove dependency onto v8::Message and simplify conversion from
QV4::Exception to QQmlError.
Change-Id: Icfdfd7a2749210b2df9fda6cd5de94114b8adcfa
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'src/qml/qml')
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlerror.h | 1 | ||||
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression.cpp | 38 | ||||
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression_p.h | 12 |
4 files changed, 26 insertions, 29 deletions
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 934b74c236..40d38a4cae 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -1645,7 +1645,7 @@ void QQmlEnginePrivate::warning(const QList<QQmlError> &errors) void QQmlEnginePrivate::warning(QQmlDelayedError *error) { Q_Q(QQmlEngine); - warning(error->error(q)); + warning(error->error()); } void QQmlEnginePrivate::warning(QQmlEngine *engine, const QQmlError &error) @@ -1669,7 +1669,7 @@ void QQmlEnginePrivate::warning(QQmlEngine *engine, QQmlDelayedError *error) if (engine) QQmlEnginePrivate::get(engine)->warning(error); else - dumpwarning(error->error(0)); + dumpwarning(error->error()); } void QQmlEnginePrivate::warning(QQmlEnginePrivate *engine, const QQmlError &error) diff --git a/src/qml/qml/qqmlerror.h b/src/qml/qml/qqmlerror.h index cea9ee4cc0..feb13d68d7 100644 --- a/src/qml/qml/qqmlerror.h +++ b/src/qml/qml/qqmlerror.h @@ -49,7 +49,6 @@ QT_BEGIN_NAMESPACE - class QDebug; class QQmlErrorPrivate; class Q_QML_EXPORT QQmlError diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 3c0e8d8919..b1c68caf99 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -63,11 +63,6 @@ bool QQmlDelayedError::addError(QQmlEnginePrivate *e) return true; } -void QQmlDelayedError::setMessage(v8::Handle<v8::Message> message) -{ - m_message = message.get(); -} - void QQmlDelayedError::setErrorLocation(const QUrl &url, quint16 line, quint16 column) { m_error.setUrl(url); @@ -80,22 +75,15 @@ void QQmlDelayedError::setErrorDescription(const QString &description) m_error.setDescription(description); } -/* - Converting from a message to an error is relatively expensive. - - We don't want to do this work for transient exceptions (exceptions - that occur during startup because of the order of binding - execution, but have gone away by the time startup has finished), so we - delay conversion until it is required for displaying the error. -*/ -void QQmlDelayedError::convertMessageToError(QQmlEngine *engine) const +void QQmlDelayedError::setError(const QV4::Exception &e) { - if (!!m_message && engine) { - QQmlExpressionPrivate::exceptionToError(v8::Handle<v8::Message>(m_message.data()), m_error); - m_message.reset(); - } + m_error.setDescription(e.value().toQString()); + m_error.setUrl(e.file()); + m_error.setLine(e.lineNumber()); + m_error.setColumn(-1); } + QQmlJavaScriptExpression::QQmlJavaScriptExpression(VTable *v) : m_vtable(v) { @@ -298,8 +286,10 @@ void QQmlJavaScriptExpression::clearError() QQmlError QQmlJavaScriptExpression::error(QQmlEngine *engine) const { - if (m_vtable.hasValue()) return m_vtable.constValue()->error(engine); - else return QQmlError(); + if (m_vtable.hasValue()) + return m_vtable.constValue()->error(); + else + return QQmlError(); } QQmlDelayedError *QQmlJavaScriptExpression::delayedError() @@ -307,6 +297,14 @@ QQmlDelayedError *QQmlJavaScriptExpression::delayedError() return &m_vtable.value(); } +void QQmlJavaScriptExpression::exceptionToError(const QV4::Exception &e, QQmlError &error) +{ + error.setUrl(e.file()); + error.setLine(e.lineNumber()); + error.setColumn(-1); + error.setDescription(e.value().toQString()); +} + void QQmlJavaScriptExpression::exceptionToError(v8::Handle<v8::Message> message, QQmlError &error) { Q_ASSERT(!message.IsEmpty()); diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index b9ce49592a..9888812093 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -77,19 +77,18 @@ public: prevError = 0; } - inline bool isValid() const { return !!m_message || m_error.isValid(); } - inline const QQmlError &error(QQmlEngine *engine) const { convertMessageToError(engine); return m_error; } - inline void clearError() { m_message.reset(); m_error = QQmlError(); } + inline bool isValid() const { return m_error.isValid(); } + inline const QQmlError &error() const { return m_error; } + inline void clearError() { m_error = QQmlError(); } - void setMessage(v8::Handle<v8::Message> message); void setErrorLocation(const QUrl &url, quint16 line, quint16 column); void setErrorDescription(const QString &description); + void setError(const QV4::Exception &e); + private: - void convertMessageToError(QQmlEngine *engine) const; mutable QQmlError m_error; - mutable QExplicitlySharedDataPointer<v8::Message> m_message; QQmlDelayedError *nextError; QQmlDelayedError **prevError; @@ -147,6 +146,7 @@ public: void clearGuards(); QQmlDelayedError *delayedError(); + static void exceptionToError(const QV4::Exception &e, QQmlError &); static void exceptionToError(v8::Handle<v8::Message>, QQmlError &); static QV4::PersistentValue evalFunction(QQmlContextData *ctxt, QObject *scope, const QString &code, const QString &filename, |