summaryrefslogtreecommitdiffstats
path: root/examples/network/secureudpserver/server.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-05-15 11:15:22 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-05-15 14:40:23 +0200
commitc6a3507de2f53e40a3aef5e55fb8167ac5425676 (patch)
tree52936d4abd071cc8a7cf11e8a2a3c87a533149c4 /examples/network/secureudpserver/server.h
parentde82d239f814cf2a717bea0defeee3732384e271 (diff)
SecureUDPServer example: use std::unique_ptr instead of QSharedPointer
The only reason the code used QSharedPointer is that it used QVector to hold a collection of them, and QVector infamously cannot hold move-only types such as std::unique_ptr. Fix by using std::vector<std::unique_ptr> instead. Also, pass the objeccts into non-sink functions by raw pointer instead of shared_ptr. As a drive-by, replace clear-following-iterate by the for-exchanged pattern. Change-Id: I605fbb98af840c1b93eab9e65c07defd6e7b39e1 Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'examples/network/secureudpserver/server.h')
-rw-r--r--examples/network/secureudpserver/server.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/examples/network/secureudpserver/server.h b/examples/network/secureudpserver/server.h
index b720368e7b..1af8aef8a2 100644
--- a/examples/network/secureudpserver/server.h
+++ b/examples/network/secureudpserver/server.h
@@ -54,6 +54,7 @@
#include <QtNetwork>
#include <vector>
+#include <memory>
QT_BEGIN_NAMESPACE
@@ -86,9 +87,8 @@ private:
void handleNewConnection(const QHostAddress &peerAddress, quint16 peerPort,
const QByteArray &clientHello);
- using DtlsConnection = QSharedPointer<QDtls>;
- void doHandshake(DtlsConnection newConnection, const QByteArray &clientHello);
- void decryptDatagram(DtlsConnection connection, const QByteArray &clientMessage);
+ void doHandshake(QDtls *newConnection, const QByteArray &clientHello);
+ void decryptDatagram(QDtls *connection, const QByteArray &clientMessage);
void shutdown();
bool listening = false;
@@ -96,7 +96,7 @@ private:
QSslConfiguration serverConfiguration;
QDtlsClientVerifier cookieSender;
- QVector<DtlsConnection> knownClients;
+ std::vector<std::unique_ptr<QDtls>> knownClients;
Q_DISABLE_COPY(DtlsServer)
};