From a7b04275082d065f392e7f18c54ea9b41507ae40 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Wed, 30 Mar 2016 11:35:41 +0300 Subject: QAbstractSocket: simplify connect timer handling Remove: - handling in abort(): timer will be stopped in resetSocketLayer(); - unneccesary checks in _q_testConnection(): if we have a valid timer we should stop it anyway; - code duplication in _q_testConnection(): do not try to stop the timer twice. Change-Id: I039ae583ae4e6c4a90dc102c7d93a30e46632374 Reviewed-by: Allan Sandfeld Jensen --- src/network/socket/qabstractsocket.cpp | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 3ce2d63a39..731afd4e36 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -1135,12 +1135,10 @@ void QAbstractSocketPrivate::_q_connectToNextAddress() */ void QAbstractSocketPrivate::_q_testConnection() { - if (socketEngine) { - if (threadData->hasEventDispatcher()) { - if (connectTimer) - connectTimer->stop(); - } + if (connectTimer) + connectTimer->stop(); + if (socketEngine) { if (socketEngine->state() == QAbstractSocket::ConnectedState) { // Fetch the parameters if our connection is completed; // otherwise, fall out and try the next address. @@ -1157,11 +1155,6 @@ void QAbstractSocketPrivate::_q_testConnection() addresses.clear(); } - if (threadData->hasEventDispatcher()) { - if (connectTimer) - connectTimer->stop(); - } - #if defined(QABSTRACTSOCKET_DEBUG) qDebug("QAbstractSocketPrivate::_q_testConnection() connection failed," " checking for alternative addresses"); @@ -2370,11 +2363,6 @@ void QAbstractSocket::abort() return; } #endif - if (d->connectTimer) { - d->connectTimer->stop(); - delete d->connectTimer; - d->connectTimer = 0; - } d->abortCalled = true; close(); -- cgit v1.2.3