diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/webchannel/qmetaobjectpublisher.cpp | 9 | ||||
-rw-r--r-- | src/webchannel/qwebchannel.h | 4 | ||||
-rw-r--r-- | src/webchannel/qwebchannel.js | 3 | ||||
-rw-r--r-- | src/webchannel/qwebchannelabstracttransport.h | 2 |
4 files changed, 11 insertions, 7 deletions
diff --git a/src/webchannel/qmetaobjectpublisher.cpp b/src/webchannel/qmetaobjectpublisher.cpp index 22df02b..324191e 100644 --- a/src/webchannel/qmetaobjectpublisher.cpp +++ b/src/webchannel/qmetaobjectpublisher.cpp @@ -451,16 +451,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); @@ -487,6 +489,7 @@ QJsonValue QMetaObjectPublisher::wrapResult(const QVariant &result, QWebChannelA objectInfo[KEY_ID] = id; if (!classInfo.isEmpty()) objectInfo[KEY_DATA] = classInfo; + return objectInfo; #ifndef QT_NO_JSVALUE } else if (result.canConvert<QJSValue>()) { diff --git a/src/webchannel/qwebchannel.h b/src/webchannel/qwebchannel.h index 0e642db..d32d017 100644 --- a/src/webchannel/qwebchannel.h +++ b/src/webchannel/qwebchannel.h @@ -35,8 +35,8 @@ #ifndef QWEBCHANNEL_H #define QWEBCHANNEL_H -#include <QObject> -#include <QJsonValue> +#include <QtCore/QObject> +#include <QtCore/QJsonValue> #include <QtWebChannel/qwebchannelglobal.h> diff --git a/src/webchannel/qwebchannel.js b/src/webchannel/qwebchannel.js index c270a95..d8c28bc 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; } @@ -365,6 +365,7 @@ function QObject(name, data, webChannel) } Object.defineProperty(object, propertyName, { + configurable: true, get: function () { var propertyValue = object.__propertyCache__[propertyIndex]; if (propertyValue === undefined) { diff --git a/src/webchannel/qwebchannelabstracttransport.h b/src/webchannel/qwebchannelabstracttransport.h index 851c622..e7f2af4 100644 --- a/src/webchannel/qwebchannelabstracttransport.h +++ b/src/webchannel/qwebchannelabstracttransport.h @@ -34,7 +34,7 @@ #ifndef QWEBCHANNELABSTRACTTRANSPORT_H #define QWEBCHANNELABSTRACTTRANSPORT_H -#include <QObject> +#include <QtCore/QObject> #include <QtWebChannel/qwebchannelglobal.h> QT_BEGIN_NAMESPACE |