aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2013-11-28 16:57:41 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-29 08:19:11 +0100
commit55b5e30901cd2616d729c61856dabe3bfda5e4f0 (patch)
treef98f90b01f4bc17e72bf0b515e78a7f2d970222e /src
parent612785f39e325b0578be89e09b0e32d7d08d471e (diff)
Fix JavaScript signal connect on alias without other handlers
The changed handlers for aliases are connected lazily in the engine. QQmlPropertyPrivate::flushSignal is responsible for that and called in other places, for example when installing a onSomeAliasPropertyChanged handler. However we were missing a call to flushSignal when doing onSomeAliasPropertyChanged.connect(...), i.e. using the JavaScript connect API. Task-number: QTBUG-30493 Change-Id: Ia3f008626fd7af3f2cfbdd30d13fb83158bed4d5 Reviewed-by: Albert Astals Cid <albert.astals@canonical.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index c48b6bf61d..85e6878f7b 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -848,7 +848,7 @@ ReturnedValue QObjectWrapper::method_connect(CallContext *ctx)
QPair<QObject *, int> signalInfo = extractQtSignal(ctx->callData->thisObject);
QObject *signalObject = signalInfo.first;
- int signalIndex = signalInfo.second;
+ int signalIndex = signalInfo.second; // in method range, not signal range!
if (signalIndex < 0)
V4THROW_ERROR("Function.prototype.connect: this object is not a signal");
@@ -882,6 +882,11 @@ ReturnedValue QObjectWrapper::method_connect(CallContext *ctx)
slot->thisObject = thisObject;
slot->function = f;
+ if (QQmlData *ddata = QQmlData::get(signalObject)) {
+ if (QQmlPropertyCache *propertyCache = ddata->propertyCache) {
+ QQmlPropertyPrivate::flushSignal(signalObject, propertyCache->methodIndexToSignalIndex(signalIndex));
+ }
+ }
QObjectPrivate::connect(signalObject, signalIndex, slot, Qt::AutoConnection);
return Encode::undefined();