diff options
author | Fredrik de Vibe <fredrik.devibe@theqtcompany.com> | 2016-03-02 16:52:22 +0100 |
---|---|---|
committer | Fredrik de Vibe <fredrik.devibe@theqtcompany.com> | 2016-03-04 08:11:54 +0000 |
commit | 48f25caac4ba0ae3a0f7c556a434a7714c028354 (patch) | |
tree | 559ac460aa46a10c8124ae6fcdd88c3b1b1e0284 /src/network/socket/qtcpserver.cpp | |
parent | 954bd06bc51a19a65c228124f971ac69dbf8ca79 (diff) | |
download | qtbase-48f25caac4ba0ae3a0f7c556a434a7714c028354.tar.gz |
Check if socketEngine is set before accessing it.
QTcpServer::addPendingConnection() is protected, so it is possible to
add pending connections from a class derived from QTcpServer. This
derived class can get a QTcpSocket from somewhere else, in which case
d->socketEngine will not be set (or used). Given that it is possible to
add pending connections in this scenario, it would make sense to be able
to retrieve them as well.
[ChangeLog][QtNetwork][QTcpServer] Permit using a QTcpServer with
externally created QTcpSocket.
Task-number: QTBUG-51288
Change-Id: I830c10f1a881e2bca4e4ad716d8be865e1c27a9f
Reviewed-by: Lars Knoll <lars.knoll@theqtcompany.com>
Diffstat (limited to 'src/network/socket/qtcpserver.cpp')
-rw-r--r-- | src/network/socket/qtcpserver.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp index 7dd884c16a..809b603403 100644 --- a/src/network/socket/qtcpserver.cpp +++ b/src/network/socket/qtcpserver.cpp @@ -543,8 +543,11 @@ QTcpSocket *QTcpServer::nextPendingConnection() if (d->pendingConnections.isEmpty()) return 0; - if (!d->socketEngine->isReadNotificationEnabled()) + if (!d->socketEngine) { + qWarning("QTcpServer::nextPendingConnection() called while not listening"); + } else if (!d->socketEngine->isReadNotificationEnabled()) { d->socketEngine->setReadNotificationEnabled(true); + } return d->pendingConnections.takeFirst(); } |