aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsfunctioninitializer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmlcompiler/qqmljsfunctioninitializer.cpp')
-rw-r--r--src/qmlcompiler/qqmljsfunctioninitializer.cpp103
1 files changed, 48 insertions, 55 deletions
diff --git a/src/qmlcompiler/qqmljsfunctioninitializer.cpp b/src/qmlcompiler/qqmljsfunctioninitializer.cpp
index ffd6bf7308..95bd243f0b 100644
--- a/src/qmlcompiler/qqmljsfunctioninitializer.cpp
+++ b/src/qmlcompiler/qqmljsfunctioninitializer.cpp
@@ -168,71 +168,64 @@ QQmlJSCompilePass::Function QQmlJSFunctionInitializer::run(
}
function.isProperty = m_objectType->hasProperty(propertyName);
- if (!function.isProperty) {
- if (QQmlSignalNames::isHandlerName(propertyName)) {
- if (auto actualPropertyName =
- QQmlSignalNames::changedHandlerNameToPropertyName(propertyName);
- actualPropertyName && m_objectType->hasProperty(*actualPropertyName)) {
- function.isSignalHandler = true;
- } else {
- auto signalName = QQmlSignalNames::handlerNameToSignalName(propertyName);
- const auto methods = m_objectType->methods(*signalName);
- for (const auto &method : methods) {
- if (method.isCloned())
- continue;
- if (method.methodType() == QQmlJSMetaMethodType::Signal) {
- function.isSignalHandler = true;
- const auto arguments = method.parameters();
- for (qsizetype i = 0, end = arguments.size(); i < end; ++i) {
- const auto &type = arguments[i].type();
- if (type.isNull()) {
- diagnose(u"Cannot resolve the argument type %1."_s.arg(
- arguments[i].typeName()),
- QtDebugMsg, bindingLocation, errors);
- function.argumentTypes.append(
- m_typeResolver->namedType(m_typeResolver->varType()));
- } else {
- function.argumentTypes.append(m_typeResolver->namedType(type));
- }
- }
- break;
- }
- }
- if (!function.isSignalHandler) {
- diagnose(u"Could not compile signal handler for %1: The signal does not exist"_s.arg(
- *signalName),
- QtWarningMsg, bindingLocation, errors);
- }
- }
- }
- }
-
- if (!function.isSignalHandler) {
- if (!function.isProperty) {
- diagnose(u"Could not compile binding for %1: The property does not exist"_s.arg(
- propertyName),
- QtWarningMsg, bindingLocation, errors);
- }
-
+ if (function.isProperty) {
const auto property = m_objectType->property(propertyName);
if (const QQmlJSScope::ConstPtr propertyType = property.type()) {
function.returnType = m_typeResolver->namedType(propertyType->isListProperty()
? m_typeResolver->qObjectListType()
: QQmlJSScope::ConstPtr(property.type()));
} else {
- QString message = u"Cannot resolve property type %1 for binding on %2."_s
- .arg(property.typeName(), propertyName);
- if (m_objectType->isNameDeferred(propertyName)) {
- // If the property doesn't exist but the name is deferred, then
- // it's deferred via the presence of immediate names. Those are
- // most commonly used to enable generalized grouped properties.
- message += u" You may want use ID-based grouped properties here.";
- }
- diagnose(message, QtWarningMsg, bindingLocation, errors);
+ diagnose(u"Cannot resolve property type %1 for binding on %2."_s
+ .arg(property.typeName(), propertyName),
+ QtWarningMsg, bindingLocation, errors);
}
if (!property.bindable().isEmpty() && !property.isPrivate())
function.isQPropertyBinding = true;
+ } else if (QQmlSignalNames::isHandlerName(propertyName)) {
+ if (auto actualPropertyName =
+ QQmlSignalNames::changedHandlerNameToPropertyName(propertyName);
+ actualPropertyName && m_objectType->hasProperty(*actualPropertyName)) {
+ function.isSignalHandler = true;
+ } else {
+ auto signalName = QQmlSignalNames::handlerNameToSignalName(propertyName);
+ const auto methods = m_objectType->methods(*signalName);
+ for (const auto &method : methods) {
+ if (method.isCloned())
+ continue;
+ if (method.methodType() == QQmlJSMetaMethodType::Signal) {
+ function.isSignalHandler = true;
+ const auto arguments = method.parameters();
+ for (qsizetype i = 0, end = arguments.size(); i < end; ++i) {
+ const auto &type = arguments[i].type();
+ if (type.isNull()) {
+ diagnose(u"Cannot resolve the argument type %1."_s.arg(
+ arguments[i].typeName()),
+ QtDebugMsg, bindingLocation, errors);
+ function.argumentTypes.append(
+ m_typeResolver->namedType(m_typeResolver->varType()));
+ } else {
+ function.argumentTypes.append(m_typeResolver->namedType(type));
+ }
+ }
+ break;
+ }
+ }
+ if (!function.isSignalHandler) {
+ diagnose(u"Could not find signal \"%1\"."_s.arg(*signalName),
+ QtWarningMsg, bindingLocation, errors);
+ }
+ }
+ } else {
+ QString message = u"Could not find property \"%1\"."_s.arg(propertyName);
+ if (m_objectType->isNameDeferred(propertyName)) {
+ // If the property doesn't exist but the name is deferred, then
+ // it's deferred via the presence of immediate names. Those are
+ // most commonly used to enable generalized grouped properties.
+ message += u" You may want use ID-based grouped properties here.";
+ }
+
+ diagnose(message, QtWarningMsg, bindingLocation, errors);
}
QQmlJS::MemoryPool pool;