summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--examples/webchannel/chatserver-cpp/chatserver.cpp9
-rw-r--r--examples/webchannel/chatserver-cpp/main.cpp12
-rw-r--r--examples/webchannel/shared/websocketclientwrapper.cpp5
-rw-r--r--src/webchannel/doc/src/index.qdoc13
-rw-r--r--src/webchannel/qmetaobjectpublisher.cpp46
-rw-r--r--src/webchannel/qmetaobjectpublisher_p.h2
-rw-r--r--tests/auto/webchannel/tst_webchannel.cpp2
8 files changed, 44 insertions, 47 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 45d16f2..556f554 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,4 +1,4 @@
load(qt_build_config)
CONFIG += warning_clean
-MODULE_VERSION = 5.7.1
+MODULE_VERSION = 5.8.0
diff --git a/examples/webchannel/chatserver-cpp/chatserver.cpp b/examples/webchannel/chatserver-cpp/chatserver.cpp
index 9bc45ce..74da4c3 100644
--- a/examples/webchannel/chatserver-cpp/chatserver.cpp
+++ b/examples/webchannel/chatserver-cpp/chatserver.cpp
@@ -115,12 +115,14 @@ bool ChatServer::sendMessage(const QString& user, const QString& msg)
}
}
-void ChatServer::sendKeepAlive() {
+void ChatServer::sendKeepAlive()
+{
emit keepAlive();
m_keepAliveCheckTimer->start();
}
-void ChatServer::checkKeepAliveResponses() {
+void ChatServer::checkKeepAliveResponses()
+{
qDebug() << "Keep Alive Check" << m_stillAliveUsers;
m_userList = m_stillAliveUsers;
m_stillAliveUsers.clear();
@@ -128,7 +130,8 @@ void ChatServer::checkKeepAliveResponses() {
emit userListChanged();
}
-void ChatServer::keepAliveResponse(const QString& user) {
+void ChatServer::keepAliveResponse(const QString& user)
+{
m_stillAliveUsers.append(user);
}
diff --git a/examples/webchannel/chatserver-cpp/main.cpp b/examples/webchannel/chatserver-cpp/main.cpp
index 240518c..ea27e87 100644
--- a/examples/webchannel/chatserver-cpp/main.cpp
+++ b/examples/webchannel/chatserver-cpp/main.cpp
@@ -49,17 +49,13 @@
****************************************************************************/
#include "qwebchannel.h"
-
-#include <QCoreApplication>
-#include <QUrl>
-#include <QDebug>
-
-#include <QtWebSockets/QWebSocketServer>
+#include "chatserver.h"
#include "../shared/websocketclientwrapper.h"
#include "../shared/websockettransport.h"
-#include "chatserver.h"
+#include <QtWebSockets/QWebSocketServer>
+#include <QCoreApplication>
int main(int argc, char** argv)
{
@@ -82,7 +78,7 @@ int main(int argc, char** argv)
// setup the dialog and publish it to the QWebChannel
ChatServer* chatserver = new ChatServer(&app);
- channel.registerObject("chatserver", chatserver);
+ channel.registerObject(QStringLiteral("chatserver"), chatserver);
return app.exec();
}
diff --git a/examples/webchannel/shared/websocketclientwrapper.cpp b/examples/webchannel/shared/websocketclientwrapper.cpp
index 0778cee..3743bdd 100644
--- a/examples/webchannel/shared/websocketclientwrapper.cpp
+++ b/examples/webchannel/shared/websocketclientwrapper.cpp
@@ -49,13 +49,12 @@
****************************************************************************/
#include "websocketclientwrapper.h"
+#include "websockettransport.h"
#include <QtWebSockets/QWebSocketServer>
-#include "websockettransport.h"
-
/*!
- \brief Wrapps connected QWebSockets clients in WebSocketTransport objects.
+ \brief Wraps connected QWebSockets clients in WebSocketTransport objects.
This code is all that is required to connect incoming WebSockets to the WebChannel. Any kind
of remote JavaScript client that supports WebSockets can thus receive messages and access the
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 d796d1e..66676f0 100644
--- a/src/webchannel/qmetaobjectpublisher.cpp
+++ b/src/webchannel/qmetaobjectpublisher.cpp
@@ -455,29 +455,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()) {
@@ -518,6 +495,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
diff --git a/tests/auto/webchannel/tst_webchannel.cpp b/tests/auto/webchannel/tst_webchannel.cpp
index dd2059e..a2c62cf 100644
--- a/tests/auto/webchannel/tst_webchannel.cpp
+++ b/tests/auto/webchannel/tst_webchannel.cpp
@@ -800,7 +800,7 @@ void TestWebChannel::benchRemoveTransport()
}
QBENCHMARK_ONCE {
- foreach (DummyTransport *transport, dummyTransports)
+ for (auto transport : dummyTransports)
pub->transportRemoved(transport);
}