summaryrefslogtreecommitdiff
path: root/src/websockets/qwebsocket.cpp
diff options
context:
space:
mode:
authorPeter Kümmel <syntheticpp@gmx.net>2015-08-24 18:34:40 +0200
committerLiang Qi <liang.qi@theqtcompany.com>2015-09-04 11:52:06 +0000
commite8335d48aa8c6323a6b89d29c76f2b340afd1be4 (patch)
tree58e30e1e8ac5cd45acc23289753d447a7d3172de /src/websockets/qwebsocket.cpp
parenta01c1455afecc2a98598a574f69ce682586357ff (diff)
downloadqtwebsockets-e8335d48aa8c6323a6b89d29c76f2b340afd1be4.tar.gz
Set parent of internal socket objects
After moving the websocket into another thread current code doesn't work because then the QTcpSocket/QSslSocket objects reside in a different thread, for instance: "QSocketNotifier: Socket notifiers cannot be enabled or disabled from another thread" QObject::moveToThread(QThread*) also moves QObjects's children, therefore their internal socket objects need to be children of QWebSocket. QWebSocket has ownership of the internal socket, and the smart pointer is not needed any more. Change of cleanup code to prevent crashes with clang/msvc builds: QWebSocketPrivate is a scoped member of QObject (not QWebSocket) and is destroyed after QObject destructor body was executed, and so m_pSocket&co had already been destroyed (being children) when the destructor of QWebSocketPrivate is called via the scoped pointer. Analogous to 64927e04f202d33b9a9a1f94141ef692c0b513ac Change-Id: I1ade6cda3fa793c30332cc5e103025e2dda3c78c Reviewed-by: Luca Niccoli <lultimouomo@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
Diffstat (limited to 'src/websockets/qwebsocket.cpp')
-rw-r--r--src/websockets/qwebsocket.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/websockets/qwebsocket.cpp b/src/websockets/qwebsocket.cpp
index a77f23c..ee9b2d2 100644
--- a/src/websockets/qwebsocket.cpp
+++ b/src/websockets/qwebsocket.cpp
@@ -281,6 +281,8 @@ QWebSocket::QWebSocket(const QString &origin,
*/
QWebSocket::~QWebSocket()
{
+ Q_D(QWebSocket);
+ d->closeGoingAway();
}
/*!