aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2016-11-30 15:37:22 +0100
committerLars Knoll <lars.knoll@qt.io>2016-12-09 08:30:54 +0000
commit68d73a253a974967e18ba23719af31fd47434585 (patch)
tree0a3092a0159089d35262d36b2a371bdcacba4217
parent55101d6937880f4dfd8d8eb79fbb15a8e7bb508a (diff)
Add sourceLocation() accessor to QQmlJavascriptExpression
And remove it from the derived QQmlBoundSignalExpression class. Change-Id: I93cdc67136ddd916474acd2169faf380e296a900 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
-rw-r--r--src/qml/qml/qqmlbinding.cpp3
-rw-r--r--src/qml/qml/qqmlboundsignal.cpp13
-rw-r--r--src/qml/qml/qqmlboundsignal_p.h1
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp5
-rw-r--r--src/qml/qml/qqmljavascriptexpression_p.h2
5 files changed, 9 insertions, 15 deletions
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index d55b4df13e..5e41ea1758 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -197,6 +197,7 @@ protected:
QQmlPropertyData::WriteFlags flags, QV4::Scope &scope,
const QV4::ScopedFunctionObject &f) Q_DECL_OVERRIDE Q_DECL_FINAL
{
+ Q_UNUSED(f);
auto ep = QQmlEnginePrivate::get(scope.engine);
ep->referenceScarceResources();
@@ -212,7 +213,7 @@ protected:
if (!watcher.wasDeleted()) {
if (error) {
- delayedError()->setErrorLocation(f->sourceLocation());
+ delayedError()->setErrorLocation(sourceLocation());
delayedError()->setErrorObject(m_target.data());
}
diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp
index 4e63790290..7b7e6562ff 100644
--- a/src/qml/qml/qqmlboundsignal.cpp
+++ b/src/qml/qml/qqmlboundsignal.cpp
@@ -157,19 +157,6 @@ void QQmlBoundSignalExpression::expressionChanged()
// bound signals do not notify on change.
}
-QQmlSourceLocation QQmlBoundSignalExpression::sourceLocation() const
-{
- QV4::Function *f = function();
- if (f) {
- QQmlSourceLocation loc;
- loc.sourceFile = f->sourceFile();
- loc.line = f->compiledFunction->location.line;
- loc.column = f->compiledFunction->location.column;
- return loc;
- }
- return QQmlSourceLocation();
-}
-
QString QQmlBoundSignalExpression::expression() const
{
if (expressionFunctionValid()) {
diff --git a/src/qml/qml/qqmlboundsignal_p.h b/src/qml/qml/qqmlboundsignal_p.h
index 10c59b07c1..2234f08497 100644
--- a/src/qml/qml/qqmlboundsignal_p.h
+++ b/src/qml/qml/qqmlboundsignal_p.h
@@ -86,7 +86,6 @@ public:
void evaluate(void **a);
void evaluate(const QList<QVariant> &args);
- QQmlSourceLocation sourceLocation() const;
QString expression() const;
QV4::Function *function() const;
QObject *target() const { return m_target; }
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 54d9222a8e..f81320aa6b 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -128,6 +128,11 @@ void QQmlJavaScriptExpression::resetNotifyOnValueChanged()
setNotifyOnValueChanged(false);
}
+QQmlSourceLocation QQmlJavaScriptExpression::sourceLocation() const
+{
+ return m_function.valueRef()->as<QV4::FunctionObject>()->sourceLocation();
+}
+
void QQmlJavaScriptExpression::setContext(QQmlContextData *context)
{
if (m_prevExpression) {
diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h
index 5f9cffb56d..038f9688a1 100644
--- a/src/qml/qml/qqmljavascriptexpression_p.h
+++ b/src/qml/qml/qqmljavascriptexpression_p.h
@@ -113,6 +113,8 @@ public:
inline QObject *scopeObject() const;
inline void setScopeObject(QObject *v);
+ QQmlSourceLocation sourceLocation() const;
+
bool isValid() const { return context() != 0; }
QQmlContextData *context() const { return m_context; }