QAbstractSocket: simplify a check for data availability

We know that the QAbstractSocketPrivate::canReadNotification() slot is
called by the engine's read notifier only when new data is available for
reading, or when the socket has been closed. This allows us to remove
additional checks for engine validity and data availability for unbuffered
sockets.

Change-Id: Ic278cf2214d418d8fe471ea24a765b8d5840b0a5
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Alex Trotsenko 2015-04-14 11:30:15 +03:00
parent 208496091d
commit 3d93fb0771

View File

@ -723,14 +723,7 @@ bool QAbstractSocketPrivate::canReadNotification()
}
// Only emit readyRead() if there is data available.
bool hasData = newBytes > 0
#ifndef QT_NO_UDPSOCKET
|| (!isBuffered && socketType != QAbstractSocket::TcpSocket && socketEngine && socketEngine->hasPendingDatagrams())
#endif
|| (!isBuffered && socketType == QAbstractSocket::TcpSocket && socketEngine)
;
if (hasData)
if (newBytes > 0 || !isBuffered)
emitReadyRead();
// If we were closed as a result of the readyRead() signal,