diff options
author | Lutz Schönemann <lutz.schoenemann@basyskom.com> | 2014-12-17 16:27:35 +0100 |
---|---|---|
committer | Tony Sarajärvi <tony.sarajarvi@digia.com> | 2015-05-15 17:58:17 +0000 |
commit | 368adbf8e75c00712c7a30eb6b8d7a7e175e89d7 (patch) | |
tree | dab3625745d0add6087c5fc69f27dbbb87d87d06 /src | |
parent | c3bcbd1dcd8df8c93924853308d7f2ec95aba825 (diff) | |
download | qtwebchannel-368adbf8e75c00712c7a30eb6b8d7a7e175e89d7.tar.gz |
Fix wrap registered object issue
When wrapping a registered object the code generated a new
ID for an already known object. That new ID wasn't stored
but returned to the client including the objects information.
That resulted in a new created object on client side but
the remote object (on the server) was not accessible.
This patch fixes the issue by just returning the known ID
of a known object. Because the client already has a local
representation of that object it does not have to unwrap
the object description.
Change-Id: I31964823c84c84fd7ebce4386865c18fb5518be7
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/webchannel/qmetaobjectpublisher.cpp | 9 | ||||
-rw-r--r-- | src/webchannel/qwebchannel.js | 2 |
2 files changed, 7 insertions, 4 deletions
diff --git a/src/webchannel/qmetaobjectpublisher.cpp b/src/webchannel/qmetaobjectpublisher.cpp index 0cad569..42c95d2 100644 --- a/src/webchannel/qmetaobjectpublisher.cpp +++ b/src/webchannel/qmetaobjectpublisher.cpp @@ -449,16 +449,18 @@ QJsonValue QMetaObjectPublisher::wrapResult(const QVariant &result, QWebChannelA { if (QObject *object = result.value<QObject *>()) { QString id = registeredObjectIds.value(object); + QJsonObject classInfo; if (id.isEmpty()) { // neither registered, nor wrapped, do so now id = QUuid::createUuid().toString(); - Q_ASSERT(!registeredObjects.contains(id)); + // store ID before the call to classInfoForObject() + // in case of self-contained objects it avoids + // infinite loops + registeredObjectIds[object] = id; classInfo = classInfoForObject(object, transport); - registeredObjectIds[object] = id; - ObjectInfo oi(object, classInfo); if (transport) { oi.transports.append(transport); @@ -485,6 +487,7 @@ QJsonValue QMetaObjectPublisher::wrapResult(const QVariant &result, QWebChannelA objectInfo[KEY_ID] = id; if (!classInfo.isEmpty()) objectInfo[KEY_DATA] = classInfo; + return objectInfo; } else if (result.canConvert<QJSValue>()) { // Workaround for keeping QJSValues from QVariant. diff --git a/src/webchannel/qwebchannel.js b/src/webchannel/qwebchannel.js index c270a95..f114e77 100644 --- a/src/webchannel/qwebchannel.js +++ b/src/webchannel/qwebchannel.js @@ -193,7 +193,7 @@ function QObject(name, data, webChannel) } if (!response || !response["__QObject*__"] - || response["id"] === undefined) { + || response.id === undefined) { return response; } |