From 2ebee301fd6629f2d5c604fd021c61c15692775f Mon Sep 17 00:00:00 2001 From: Maximilian Goldstein Date: Mon, 2 May 2022 16:51:01 +0200 Subject: Reimplement PropertyPass to evaluate bindings This change reimplements the PropertyPass to be based on bindings rather than on just iterating over elements. This is a lot less cost intensive than iterating over all properties regardless of whether they are actually used. You may still achieve the same thing with the more flexible element pass, just with the benefit that you can choose what properties you want to iterate over instead of iterating over all of them. To demonstrate the passes usefulness the existing attached property warnings are ported to use the binding pass and can now also warn when an attached property is read or written in a context where it's not supposed to be used. Fixes: QTBUG-102860 Fixes: QTBUG-102418 Task-number: QTBUG-102859 Change-Id: Iea87a1b05b954429b8bf00fd27b60487940af679 Reviewed-by: Ulf Hermann Reviewed-by: Qt CI Bot --- src/qmlcompiler/qqmljsfunctioninitializer.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/qmlcompiler/qqmljsfunctioninitializer.cpp') diff --git a/src/qmlcompiler/qqmljsfunctioninitializer.cpp b/src/qmlcompiler/qqmljsfunctioninitializer.cpp index 91a6de790d..2fd9ff6f57 100644 --- a/src/qmlcompiler/qqmljsfunctioninitializer.cpp +++ b/src/qmlcompiler/qqmljsfunctioninitializer.cpp @@ -156,8 +156,8 @@ QQmlJSCompilePass::Function QQmlJSFunctionInitializer::run( QtDebugMsg, bindingLocation, error); } - const bool isProperty = m_objectType->hasProperty(propertyName); - if (!isProperty && QmlIR::IRBuilder::isSignalPropertyName(propertyName)) { + function.isProperty = m_objectType->hasProperty(propertyName); + if (!function.isProperty && QmlIR::IRBuilder::isSignalPropertyName(propertyName)) { const QString signalName = QmlIR::IRBuilder::signalNameFromSignalPropertyName(propertyName); if (signalName.endsWith(u"Changed"_s) @@ -180,9 +180,8 @@ QQmlJSCompilePass::Function QQmlJSFunctionInitializer::run( } } - if (!function.isSignalHandler) { - if (!isProperty) { + if (!function.isProperty) { diagnose(u"Could not compile binding for %1: The property does not exist"_s.arg( propertyName), QtWarningMsg, bindingLocation, error); -- cgit v1.2.3