diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/imports/webchannel/plugin.cpp | 2 | ||||
-rw-r--r-- | src/webchannel/doc/src/index.qdoc | 13 | ||||
-rw-r--r-- | src/webchannel/qmetaobjectpublisher.cpp | 46 | ||||
-rw-r--r-- | src/webchannel/qmetaobjectpublisher_p.h | 2 |
4 files changed, 31 insertions, 32 deletions
diff --git a/src/imports/webchannel/plugin.cpp b/src/imports/webchannel/plugin.cpp index 3779de3..c66f75f 100644 --- a/src/imports/webchannel/plugin.cpp +++ b/src/imports/webchannel/plugin.cpp @@ -55,7 +55,7 @@ QT_BEGIN_NAMESPACE class QWebChannelPlugin : public QQmlExtensionPlugin { Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") + Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid) public: QWebChannelPlugin(QObject *parent = 0) : QQmlExtensionPlugin(parent) { initResources(); } diff --git a/src/webchannel/doc/src/index.qdoc b/src/webchannel/doc/src/index.qdoc index 43f4e6f..5529093 100644 --- a/src/webchannel/doc/src/index.qdoc +++ b/src/webchannel/doc/src/index.qdoc @@ -31,13 +31,12 @@ \title Qt WebChannel \brief Bridges the gap between Qt applications and HTML/JavaScript. - Qt WebChannel enables peer-to-peer communication between the server - (QML/C++ application) and the client (HTML/JavaScript or QML application). The - transport mechanism is supported out of the box by \l{Qt WebEngine}. It works on all - browsers that support \l{Qt WebSockets}, enabling Qt WebChannel applications - to run in any JavaScript runtime. Additionally, a custom transport - mechanism can also be implemented using Qt WebSockets to support Qt - WebChannel-based communication. + Qt WebChannel enables peer-to-peer communication between a server (QML/C++ + application) and a client (HTML/JavaScript or QML application). It is + supported out of the box by \l{Qt WebEngine}. In addition it can work on all + browsers that support \l{Qt WebSockets}{WebSockets}, enabling Qt WebChannel + clients to run in any JavaScript environment (including QML). This requires + the implementation of a custom transport based on Qt WebSockets. The module provides a JavaScript library for seamless integration of C++ and QML applications with HTML/JavaScript and QML clients. The clients must use the diff --git a/src/webchannel/qmetaobjectpublisher.cpp b/src/webchannel/qmetaobjectpublisher.cpp index b4747d4..148404d 100644 --- a/src/webchannel/qmetaobjectpublisher.cpp +++ b/src/webchannel/qmetaobjectpublisher.cpp @@ -459,29 +459,6 @@ void QMetaObjectPublisher::objectDestroyed(const QObject *object) pendingPropertyUpdates.remove(object); } -void QMetaObjectPublisher::transportRemoved(QWebChannelAbstractTransport *transport) -{ - QHash<QWebChannelAbstractTransport*, QString>::iterator it = transportedWrappedObjects.find(transport); - // It is not allowed to modify a container while iterating over it. So save - // objects which should be removed and call objectDestroyed() on them later. - QVector<QObject*> objectsForDeletion; - while (it != transportedWrappedObjects.end() && it.key() == transport) { - if (wrappedObjects.contains(it.value())) { - QVector<QWebChannelAbstractTransport*> &transports = wrappedObjects[it.value()].transports; - transports.removeOne(transport); - if (transports.isEmpty()) - objectsForDeletion.append(wrappedObjects[it.value()].object); - } - - it++; - } - - transportedWrappedObjects.remove(transport); - - foreach (QObject *obj, objectsForDeletion) - objectDestroyed(obj); -} - QObject *QMetaObjectPublisher::unwrapObject(const QString &objectId) const { if (!objectId.isEmpty()) { @@ -522,6 +499,29 @@ QVariant QMetaObjectPublisher::toVariant(const QJsonValue &value, int targetType return variant; } +void QMetaObjectPublisher::transportRemoved(QWebChannelAbstractTransport *transport) +{ + auto it = transportedWrappedObjects.find(transport); + // It is not allowed to modify a container while iterating over it. So save + // objects which should be removed and call objectDestroyed() on them later. + QVector<QObject*> objectsForDeletion; + while (it != transportedWrappedObjects.end() && it.key() == transport) { + if (wrappedObjects.contains(it.value())) { + QVector<QWebChannelAbstractTransport*> &transports = wrappedObjects[it.value()].transports; + transports.removeOne(transport); + if (transports.isEmpty()) + objectsForDeletion.append(wrappedObjects[it.value()].object); + } + + it++; + } + + transportedWrappedObjects.remove(transport); + + foreach (QObject *obj, objectsForDeletion) + objectDestroyed(obj); +} + // NOTE: transport can be a nullptr // in such a case, we need to ensure that the property is registered to // the target transports of the parentObjectId diff --git a/src/webchannel/qmetaobjectpublisher_p.h b/src/webchannel/qmetaobjectpublisher_p.h index 3ccd7d4..830e510 100644 --- a/src/webchannel/qmetaobjectpublisher_p.h +++ b/src/webchannel/qmetaobjectpublisher_p.h @@ -94,7 +94,7 @@ public: virtual ~QMetaObjectPublisher(); /** - * Register @p object nuder the given @p id. + * Register @p object under the given @p id. * * The properties, signals and public methods of the QObject are * published to the remote client, where an object with the given identifier |