From 67b73ad00904981d001bd752feae39b73407c103 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 23 Mar 2020 14:54:00 +0100 Subject: 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 Reviewed-by: Fabian Kosmale --- src/qml/qml/qqmlbinding.cpp | 12 ------------ src/qml/qml/qqmlbinding_p.h | 1 - src/qml/qml/qqmljavascriptexpression.cpp | 12 ++++++++++++ src/qml/qml/qqmljavascriptexpression_p.h | 2 +- 4 files changed, 13 insertions(+), 14 deletions(-) (limited to 'src') 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 >()); } -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); -- cgit v1.2.3