aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlobjectcreator.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-01-30 13:31:14 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-03 14:37:53 +0100
commitd5f5083f1f6ea78f7b8527a1352569fad2ab643a (patch)
treee5b9c7ec8235c5cd9b176510125f86b24928c6e0 /src/qml/qml/qqmlobjectcreator.cpp
parenta52df12dcdce81af690cff3275eb195a282bae91 (diff)
[new compiler] Add support for signal handler objects
Change-Id: I644dcea86fa886a6a2dc7cd230ad6942d165c4c5 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqmlobjectcreator.cpp')
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index b7dc1f4b94..0c2b4a8bc4 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -722,6 +722,30 @@ bool QmlObjectCreator::setPropertyValue(QQmlPropertyData *property, int bindingI
return false;
}
+ // Assigning object to signal property?
+ if (binding->flags & QV4::CompiledData::Binding::IsSignalHandlerObject) {
+ if (!property->isFunction()) {
+ recordError(binding->valueLocation, tr("Cannot assign an object to signal property %1").arg(property->name(_qobject)));
+ return false;
+ }
+ QMetaMethod method = QQmlMetaType::defaultMethod(createdSubObject);
+ if (!method.isValid()) {
+ recordError(binding->valueLocation, tr("Cannot assign object type %1 with no default method").arg(QString::fromLatin1(createdSubObject->metaObject()->className())));
+ return false;
+ }
+
+ QMetaMethod signalMethod = _qobject->metaObject()->method(property->coreIndex);
+ if (!QMetaObject::checkConnectArgs(signalMethod, method)) {
+ recordError(binding->valueLocation, tr("Cannot connect mismatched signal/slot %1 %vs. %2")
+ .arg(QString::fromLatin1(method.methodSignature().constData()))
+ .arg(QString::fromLatin1(signalMethod.methodSignature().constData())));
+ return false;
+ }
+
+ QQmlPropertyPrivate::connect(_qobject, property->coreIndex, createdSubObject, method.methodIndex());
+ return true;
+ }
+
QQmlPropertyPrivate::WriteFlags propertyWriteFlags = QQmlPropertyPrivate::BypassInterceptor |
QQmlPropertyPrivate::RemoveBindingOnAliasWrite;
int propertyWriteStatus = -1;