summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/webchannel/qmetaobjectpublisher.cpp5
-rw-r--r--tests/auto/qml/tst_webchannel.qml30
2 files changed, 33 insertions, 2 deletions
diff --git a/src/webchannel/qmetaobjectpublisher.cpp b/src/webchannel/qmetaobjectpublisher.cpp
index eb2fdbd..a6e3e65 100644
--- a/src/webchannel/qmetaobjectpublisher.cpp
+++ b/src/webchannel/qmetaobjectpublisher.cpp
@@ -441,15 +441,16 @@ QJsonValue QMetaObjectPublisher::wrapResult(const QVariant &result)
const QString &id = QUuid::createUuid().toString();
Q_ASSERT(!registeredObjectIds.contains(object));
+ QJsonObject info = classInfoForObject(object);
objectInfo[KEY_QOBJECT] = true;
objectInfo[KEY_ID] = id;
- objectInfo[KEY_DATA] = classInfoForObject(object);
+ objectInfo[KEY_DATA] = info;
registeredObjectIds[object] = id;
registeredObjects[id] = object;
wrappedObjects.insert(object, objectInfo);
- initializePropertyUpdates(object, objectInfo);
+ initializePropertyUpdates(object, info);
return objectInfo;
}
diff --git a/tests/auto/qml/tst_webchannel.qml b/tests/auto/qml/tst_webchannel.qml
index cd7d14e..46ac209 100644
--- a/tests/auto/qml/tst_webchannel.qml
+++ b/tests/auto/qml/tst_webchannel.qml
@@ -303,6 +303,36 @@ TestCase {
compare(typeof channel.objects[testObjId], "undefined");
}
+ function test_wrapper_propertyUpdateOfWrappedObjects() {
+ var testObj;
+ var testObjId;
+ var channel = client.createChannel(function(channel) {
+ channel.objects.myFactory.create("testObj", function(obj) {
+ testObj = myFactory.lastObj;
+ testObjId = obj.__id__;
+ });
+ });
+ client.awaitInit();
+
+ // first message (call to myFactory.create())
+ var msg = client.awaitMessage();
+ compare(msg.type, JSClient.QWebChannelMessageTypes.invokeMethod);
+
+ // second message connects to destroyed signal
+ msg = client.awaitMessage();
+ compare(msg.type, JSClient.QWebChannelMessageTypes.connectToSignal);
+
+ client.awaitIdle();
+
+ testObj.myProperty = 42;
+ client.awaitIdle();
+ compare(channel.objects[testObjId].myProperty, 42);
+
+ channel.objects[testObjId].deleteLater();
+ msg = client.awaitMessage();
+ compare(msg.type, JSClient.QWebChannelMessageTypes.invokeMethod);
+ }
+
function test_disconnect()
{
var signalArg;