summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKimmo Karvinen <kkarvinen@broadsoft.com>2015-03-31 17:14:33 +0300
committerLiang Qi <liang.qi@theqtcompany.com>2015-04-08 06:54:53 +0000
commit5b469aa3c4d6b9c68feb9cf92d03614077518894 (patch)
tree8d0889cd7eb6a389052e6a02978805a2f8092725 /src
parent8a370cead2f493ee961c814af96192a8db3e18e3 (diff)
downloadqtwebsockets-5b469aa3c4d6b9c68feb9cf92d03614077518894.tar.gz
Fixed a crash when destroying the QWebSocketServerv5.4.25.4.2
Lifetime of incoming QTcpSocket/QSslSocket are managed by the QTcpServer/QSslServer and thus the QWebSocketPrivate should clear the pointer to the socket when the socket is destroyed. Added auto test for the crash. Task-number: QTBUG-45331 Change-Id: I6e30e7cdcca22aa810ccc1a1d4d7d77c7cb2c349 Reviewed-by: Steven Ceuppens <steven.ceuppens@icloud.com> Reviewed-by: Liang Qi <liang.qi@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/websockets/qwebsocket_p.cpp11
-rw-r--r--src/websockets/qwebsocket_p.h2
2 files changed, 13 insertions, 0 deletions
diff --git a/src/websockets/qwebsocket_p.cpp b/src/websockets/qwebsocket_p.cpp
index ced197e..76a5882 100644
--- a/src/websockets/qwebsocket_p.cpp
+++ b/src/websockets/qwebsocket_p.cpp
@@ -542,6 +542,10 @@ void QWebSocketPrivate::makeConnections(const QTcpSocket *pTcpSocket)
QObject::connect(pTcpSocket, &QAbstractSocket::aboutToClose, q, &QWebSocket::aboutToClose);
QObject::connect(pTcpSocket, &QAbstractSocket::bytesWritten, q, &QWebSocket::bytesWritten);
+
+ QObjectPrivate::connect(pTcpSocket, &QObject::destroyed,
+ this, &QWebSocketPrivate::socketDestroyed);
+
//catch signals
QObjectPrivate::connect(pTcpSocket, &QAbstractSocket::stateChanged, this,
&QWebSocketPrivate::processStateChanged);
@@ -1048,6 +1052,13 @@ void QWebSocketPrivate::processStateChanged(QAbstractSocket::SocketState socketS
}
}
+void QWebSocketPrivate::socketDestroyed(QObject *socket)
+{
+ Q_ASSERT(m_pSocket);
+ if (m_pSocket.data() == socket)
+ m_pSocket.take();
+}
+
/*!
\internal
*/
diff --git a/src/websockets/qwebsocket_p.h b/src/websockets/qwebsocket_p.h
index f13e08d..85d3f49 100644
--- a/src/websockets/qwebsocket_p.h
+++ b/src/websockets/qwebsocket_p.h
@@ -162,6 +162,8 @@ private:
void setSocketState(QAbstractSocket::SocketState state);
void setErrorString(const QString &errorString);
+ void socketDestroyed(QObject *socket);
+
void processData();
void processPing(const QByteArray &data);
void processPong(const QByteArray &data);