summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--src/imports/webchannel/dependencies.json2
-rw-r--r--src/imports/webchannel/plugin.cpp3
-rw-r--r--src/imports/webchannel/plugins.qmltypes5
-rw-r--r--src/imports/webchannel/webchannel.pro2
-rw-r--r--src/webchannel/doc/src/index.qdoc6
-rw-r--r--src/webchannel/doc/src/module.qdoc8
-rw-r--r--src/webchannel/qmetaobjectpublisher.cpp8
-rw-r--r--src/webchannel/qqmlwebchannel.cpp4
-rw-r--r--src/webchannel/qwebchannel.cpp10
-rw-r--r--tests/auto/webchannel/tst_webchannel.cpp33
-rw-r--r--tests/auto/webchannel/tst_webchannel.h3
12 files changed, 63 insertions, 23 deletions
diff --git a/.qmake.conf b/.qmake.conf
index a3c853d..7b49e2c 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,4 +1,4 @@
load(qt_build_config)
CONFIG += warning_clean
-MODULE_VERSION = 5.12.3
+MODULE_VERSION = 5.13.0
diff --git a/src/imports/webchannel/dependencies.json b/src/imports/webchannel/dependencies.json
new file mode 100644
index 0000000..0d4f101
--- /dev/null
+++ b/src/imports/webchannel/dependencies.json
@@ -0,0 +1,2 @@
+[
+]
diff --git a/src/imports/webchannel/plugin.cpp b/src/imports/webchannel/plugin.cpp
index 1abf648..b6d4018 100644
--- a/src/imports/webchannel/plugin.cpp
+++ b/src/imports/webchannel/plugin.cpp
@@ -60,6 +60,9 @@ void QWebChannelPlugin::registerTypes(const char *uri)
int major = 1;
int minor = 0;
qmlRegisterType<QQmlWebChannel>(uri, major, minor, "WebChannel");
+
+ // Auto-increment the import to stay in sync with ALL future QtQuick minor versions
+ qmlRegisterModule(uri, major, QT_VERSION_MINOR);
}
QT_END_NAMESPACE
diff --git a/src/imports/webchannel/plugins.qmltypes b/src/imports/webchannel/plugins.qmltypes
index 4d0155d..76cf5e4 100644
--- a/src/imports/webchannel/plugins.qmltypes
+++ b/src/imports/webchannel/plugins.qmltypes
@@ -1,12 +1,13 @@
-import QtQuick.tooling 1.1
+import QtQuick.tooling 1.2
// This file describes the plugin-supplied types contained in the library.
// It is used for QML tooling purposes only.
//
// This file was auto-generated by:
-// 'qmlplugindump -nonrelocatable QtWebChannel 1.0'
+// 'qmlplugindump -nonrelocatable -dependencies dependencies.json QtWebChannel 1.13'
Module {
+ dependencies: []
Component {
name: "QQmlWebChannel"
prototype: "QWebChannel"
diff --git a/src/imports/webchannel/webchannel.pro b/src/imports/webchannel/webchannel.pro
index 4c8d322..fd69605 100644
--- a/src/imports/webchannel/webchannel.pro
+++ b/src/imports/webchannel/webchannel.pro
@@ -3,7 +3,7 @@ QT = core quick webchannel-private
INCLUDEPATH += ../../webchannel
VPATH += ../../webchannel
-IMPORT_VERSION = 1.0
+IMPORT_VERSION = 1.$$QT_MINOR_VERSION
SOURCES += \
plugin.cpp
diff --git a/src/webchannel/doc/src/index.qdoc b/src/webchannel/doc/src/index.qdoc
index 439c4a3..17f6d15 100644
--- a/src/webchannel/doc/src/index.qdoc
+++ b/src/webchannel/doc/src/index.qdoc
@@ -59,9 +59,9 @@
\endcode
The QML types are accessed by using:
- \badcode
- import QtWebChannel 1.0
- \endcode
+ \qml \QtMinorVersion
+ import QtWebChannel 1.\1
+ \endqml
\section1 Licenses
diff --git a/src/webchannel/doc/src/module.qdoc b/src/webchannel/doc/src/module.qdoc
index 1462609..1a46b3c 100644
--- a/src/webchannel/doc/src/module.qdoc
+++ b/src/webchannel/doc/src/module.qdoc
@@ -48,13 +48,13 @@
*/
/*!
- \qmlmodule QtWebChannel 1.0
+ \qmlmodule QtWebChannel 1.\QtMinorVersion
\title Qt WebChannel QML Types
\since 5.4
\brief List of QML types that provide WebChannel functionality.
The QML types are accessed by using:
- \badcode
- import QtWebChannel 1.0
- \endcode
+ \qml \QtMinorVersion
+ import QtWebChannel 1.\1
+ \endqml
*/
diff --git a/src/webchannel/qmetaobjectpublisher.cpp b/src/webchannel/qmetaobjectpublisher.cpp
index 3b2c016..c9285b7 100644
--- a/src/webchannel/qmetaobjectpublisher.cpp
+++ b/src/webchannel/qmetaobjectpublisher.cpp
@@ -591,11 +591,9 @@ QJsonValue QMetaObjectPublisher::wrapResult(const QVariant &result, QWebChannelA
} else if (wrappedObjects.contains(id)) {
Q_ASSERT(object == wrappedObjects.value(id).object);
// check if this transport is already assigned to the object
- if (transport) {
- if (!wrappedObjects.value(id).transports.contains(transport))
- wrappedObjects[id].transports.append(transport);
- if (!transportedWrappedObjects.contains(transport, id))
- transportedWrappedObjects.insertMulti(transport, id);
+ if (transport && !wrappedObjects.value(id).transports.contains(transport)) {
+ wrappedObjects[id].transports.append(transport);
+ transportedWrappedObjects.insert(transport, id);
}
classInfo = wrappedObjects.value(id).classinfo;
}
diff --git a/src/webchannel/qqmlwebchannel.cpp b/src/webchannel/qqmlwebchannel.cpp
index d23ebef..20f6e73 100644
--- a/src/webchannel/qqmlwebchannel.cpp
+++ b/src/webchannel/qqmlwebchannel.cpp
@@ -134,8 +134,8 @@ QQmlWebChannel::~QQmlWebChannel()
/*!
\qmlmethod void WebChannel::registerObjects(QVariantMap objects)
- Registers objects to make them accessible to HTML clients. The key of the
- map is used as an identifier for the object on the client side.
+ Registers the specified \a objects to make them accessible to HTML clients.
+ The key of the map is used as an identifier for the object on the client side.
Once registered, all signals and property changes are automatically propagated to the clients.
Public invokable methods, including slots, are also accessible to the clients.
diff --git a/src/webchannel/qwebchannel.cpp b/src/webchannel/qwebchannel.cpp
index 0e9a4c5..050d04e 100644
--- a/src/webchannel/qwebchannel.cpp
+++ b/src/webchannel/qwebchannel.cpp
@@ -46,6 +46,8 @@
#include <QJsonDocument>
#include <QJsonObject>
+#include <algorithm>
+
QT_BEGIN_NAMESPACE
/*!
@@ -81,10 +83,10 @@ QT_BEGIN_NAMESPACE
*/
void QWebChannelPrivate::_q_transportDestroyed(QObject *object)
{
- QWebChannelAbstractTransport *transport = static_cast<QWebChannelAbstractTransport*>(object);
- const int idx = transports.indexOf(transport);
- if (idx != -1) {
- transports.remove(idx);
+ auto it = std::find(transports.begin(), transports.end(), object);
+ if (it != transports.end()) {
+ auto *transport = *it;
+ transports.erase(it);
publisher->transportRemoved(transport);
}
}
diff --git a/tests/auto/webchannel/tst_webchannel.cpp b/tests/auto/webchannel/tst_webchannel.cpp
index 57aab53..9a0f575 100644
--- a/tests/auto/webchannel/tst_webchannel.cpp
+++ b/tests/auto/webchannel/tst_webchannel.cpp
@@ -1115,6 +1115,39 @@ void TestWebChannel::qtbug46548_overriddenProperties()
#endif // WEBCHANNEL_TESTS_CAN_USE_JS_ENGINE
}
+void TestWebChannel::qtbug62388_wrapObjectMultipleTransports()
+{
+ QWebChannel channel;
+ TestObject obj;
+
+ auto initTransport = [&channel](QWebChannelAbstractTransport *transport) {
+ channel.connectTo(transport);
+ channel.d_func()->publisher->initializeClient(transport);
+ };
+ initTransport(m_dummyTransport);
+
+ auto queryObjectInfo = [&channel](QObject *obj, QWebChannelAbstractTransport *transport) {
+ return channel.d_func()->publisher->wrapResult(QVariant::fromValue(obj), transport).toObject();
+ };
+ const auto objectInfo = queryObjectInfo(&obj, m_dummyTransport);
+
+ QCOMPARE(objectInfo.length(), 3);
+ QVERIFY(objectInfo.contains("id"));
+ QVERIFY(objectInfo.contains("__QObject*__"));
+ QVERIFY(objectInfo.contains("data"));
+ QVERIFY(objectInfo.value("__QObject*__").isBool() && objectInfo.value("__QObject*__").toBool());
+
+ const auto id = objectInfo.value("id").toString();
+
+ QCOMPARE(channel.d_func()->publisher->unwrapObject(id), &obj);
+
+ DummyTransport transport;
+ initTransport(&transport);
+ QCOMPARE(queryObjectInfo(&obj, &transport), objectInfo);
+
+ // don't crash when the transport is destroyed
+}
+
QTEST_MAIN(TestWebChannel)
#include "tst_webchannel.moc"
diff --git a/tests/auto/webchannel/tst_webchannel.h b/tests/auto/webchannel/tst_webchannel.h
index 3d725f4..3d16f7b 100644
--- a/tests/auto/webchannel/tst_webchannel.h
+++ b/tests/auto/webchannel/tst_webchannel.h
@@ -45,7 +45,7 @@ class DummyTransport : public QWebChannelAbstractTransport
{
Q_OBJECT
public:
- explicit DummyTransport(QObject *parent)
+ explicit DummyTransport(QObject *parent = nullptr)
: QWebChannelAbstractTransport(parent)
{}
~DummyTransport() {};
@@ -329,6 +329,7 @@ private slots:
void benchRemoveTransport();
void qtbug46548_overriddenProperties();
+ void qtbug62388_wrapObjectMultipleTransports();
private:
DummyTransport *m_dummyTransport;