diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2020-03-23 14:54:00 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2020-03-23 15:01:53 +0100 |
commit | 67b73ad00904981d001bd752feae39b73407c103 (patch) | |
tree | 746abcbff6adbd340e8943f12660ca160601ea94 /src | |
parent | 619dfbe8d02347cedb93a949cde627ec4424e0ae (diff) |
Minor cleanup in QQmlJavaScriptExpression
We _can_ provide a default implementation for expressionIdentifier() -
it doesn't have to be located in QQmlBinding as it only uses fields from
QQmlJavaScriptExpression.
Change-Id: Ifcead72c4f3ed4597cde732afca466eba83f5e0d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/qml/qqmlbinding.cpp | 12 | ||||
-rw-r--r-- | src/qml/qml/qqmlbinding_p.h | 1 | ||||
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression.cpp | 12 | ||||
-rw-r--r-- | src/qml/qml/qqmljavascriptexpression_p.h | 2 |
4 files changed, 13 insertions, 14 deletions
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp index e8e57eb725..feb3fa9623 100644 --- a/src/qml/qml/qqmlbinding.cpp +++ b/src/qml/qml/qqmlbinding.cpp @@ -535,18 +535,6 @@ QVariant QQmlBinding::evaluate() return scope.engine->toVariant(result, qMetaTypeId<QList<QObject*> >()); } -QString QQmlBinding::expressionIdentifier() const -{ - if (auto f = function()) { - QString url = f->sourceFile(); - uint lineNumber = f->compiledFunction->location.line; - uint columnNumber = f->compiledFunction->location.column; - return url + QString::asprintf(":%u:%u", lineNumber, columnNumber); - } - - return QStringLiteral("[native code]"); -} - void QQmlBinding::expressionChanged() { update(); diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h index 5c9a15bec3..09f5dfc0e1 100644 --- a/src/qml/qml/qqmlbinding_p.h +++ b/src/qml/qml/qqmlbinding_p.h @@ -111,7 +111,6 @@ public: QVariant evaluate(); - QString expressionIdentifier() const override; void expressionChanged() override; QQmlSourceLocation sourceLocation() const override; diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index 93af2d7c52..3e204c1898 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -115,6 +115,18 @@ QQmlJavaScriptExpression::~QQmlJavaScriptExpression() m_scopeObject.asT2()->_s = nullptr; } +QString QQmlJavaScriptExpression::expressionIdentifier() const +{ + if (auto f = function()) { + QString url = f->sourceFile(); + uint lineNumber = f->compiledFunction->location.line; + uint columnNumber = f->compiledFunction->location.column; + return url + QString::asprintf(":%u:%u", lineNumber, columnNumber); + } + + return QStringLiteral("[native code]"); +} + void QQmlJavaScriptExpression::setNotifyOnValueChanged(bool v) { activeGuards.setFlagValue(v); diff --git a/src/qml/qml/qqmljavascriptexpression_p.h b/src/qml/qml/qqmljavascriptexpression_p.h index 6e904f15f5..b52e978938 100644 --- a/src/qml/qml/qqmljavascriptexpression_p.h +++ b/src/qml/qml/qqmljavascriptexpression_p.h @@ -102,7 +102,7 @@ public: QQmlJavaScriptExpression(); virtual ~QQmlJavaScriptExpression(); - virtual QString expressionIdentifier() const = 0; + virtual QString expressionIdentifier() const; virtual void expressionChanged() = 0; QV4::ReturnedValue evaluate(bool *isUndefined); |