diff options
| author | Alexander Akulich <akulichalexander@gmail.com> | 2020-02-07 17:29:33 +0300 |
|---|---|---|
| committer | Timur Pocheptsov <timur.pocheptsov@qt.io> | 2020-02-27 13:56:45 +0100 |
| commit | cb26a4da69db434d4227bc16e41187f3db93c984 (patch) | |
| tree | 6f047493668c04ef721831b271e49a0e2802ab2c /src | |
| parent | 469c3338407a5cf74c5e35c43ebb48c14e21ecac (diff) | |
QAbstractSocket: deprecate 'error' signal, use 'errorOccurred' instead
[ChangeLog][Deprecation Notice] QAbstractSocket::error() (the signal) is deprecated; superseded by errorOccurred()
Change-Id: I11e9c774d7c6096d1e9b37c451cf0b99188b6aad
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src')
| -rw-r--r-- | src/network/access/qftp.cpp | 6 | ||||
| -rw-r--r-- | src/network/access/qhttpnetworkconnectionchannel.cpp | 2 | ||||
| -rw-r--r-- | src/network/access/qnetworkaccessdebugpipebackend.cpp | 2 | ||||
| -rw-r--r-- | src/network/socket/qabstractsocket.cpp | 34 | ||||
| -rw-r--r-- | src/network/socket/qabstractsocket.h | 4 | ||||
| -rw-r--r-- | src/network/socket/qhttpsocketengine.cpp | 2 | ||||
| -rw-r--r-- | src/network/socket/qlocalsocket.h | 4 | ||||
| -rw-r--r-- | src/network/socket/qlocalsocket_p.h | 4 | ||||
| -rw-r--r-- | src/network/socket/qlocalsocket_tcp.cpp | 6 | ||||
| -rw-r--r-- | src/network/socket/qlocalsocket_unix.cpp | 6 | ||||
| -rw-r--r-- | src/network/socket/qsocks5socketengine.cpp | 8 | ||||
| -rw-r--r-- | src/network/socket/qsocks5socketengine_p.h | 4 | ||||
| -rw-r--r-- | src/network/ssl/qsslsocket.cpp | 2 |
13 files changed, 50 insertions, 34 deletions
diff --git a/src/network/access/qftp.cpp b/src/network/access/qftp.cpp index cda800ce354..2589c64b1c4 100644 --- a/src/network/access/qftp.cpp +++ b/src/network/access/qftp.cpp @@ -324,7 +324,7 @@ void QFtpDTP::connectToHost(const QString & host, quint16 port) socket->setObjectName(QLatin1String("QFtpDTP Passive state socket")); connect(socket, SIGNAL(connected()), SLOT(socketConnected())); connect(socket, SIGNAL(readyRead()), SLOT(socketReadyRead())); - connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError))); + connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError))); connect(socket, SIGNAL(disconnected()), SLOT(socketConnectionClosed())); connect(socket, SIGNAL(bytesWritten(qint64)), SLOT(socketBytesWritten(qint64))); @@ -769,7 +769,7 @@ void QFtpDTP::setupSocket() socket->setObjectName(QLatin1String("QFtpDTP Active state socket")); connect(socket, SIGNAL(connected()), SLOT(socketConnected())); connect(socket, SIGNAL(readyRead()), SLOT(socketReadyRead())); - connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError))); + connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), SLOT(socketError(QAbstractSocket::SocketError))); connect(socket, SIGNAL(disconnected()), SLOT(socketConnectionClosed())); connect(socket, SIGNAL(bytesWritten(qint64)), SLOT(socketBytesWritten(qint64))); @@ -807,7 +807,7 @@ QFtpPI::QFtpPI(QObject *parent) : SLOT(connectionClosed())); connect(&commandSocket, SIGNAL(readyRead()), SLOT(readyRead())); - connect(&commandSocket, SIGNAL(error(QAbstractSocket::SocketError)), + connect(&commandSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), SLOT(error(QAbstractSocket::SocketError))); connect(&dtp, SIGNAL(connectState(int)), diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index ccdb1cd6cd5..319c4953b10 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -157,7 +157,7 @@ void QHttpNetworkConnectionChannel::init() QObject::connect(socket, SIGNAL(disconnected()), this, SLOT(_q_disconnected()), Qt::DirectConnection); - QObject::connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), + QObject::connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SLOT(_q_error(QAbstractSocket::SocketError)), Qt::DirectConnection); diff --git a/src/network/access/qnetworkaccessdebugpipebackend.cpp b/src/network/access/qnetworkaccessdebugpipebackend.cpp index 03ffc696285..0029df41fe5 100644 --- a/src/network/access/qnetworkaccessdebugpipebackend.cpp +++ b/src/network/access/qnetworkaccessdebugpipebackend.cpp @@ -98,7 +98,7 @@ void QNetworkAccessDebugPipeBackend::open() // socket ready read -> we can push from socket to downstream connect(&socket, SIGNAL(readyRead()), SLOT(socketReadyRead())); - connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), SLOT(socketError())); + connect(&socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), SLOT(socketError())); connect(&socket, SIGNAL(disconnected()), SLOT(socketDisconnected())); connect(&socket, SIGNAL(connected()), SLOT(socketConnected())); // socket bytes written -> we can push more from upstream to socket diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index 57dec59bc74..fb792e428f1 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -84,7 +84,7 @@ HostLookupState. If the host is found, QAbstractSocket enters ConnectingState and emits the hostFound() signal. When the connection has been established, it enters ConnectedState and - emits connected(). If an error occurs at any stage, error() is + emits connected(). If an error occurs at any stage, errorOccurred() is emitted. Whenever the state changes, stateChanged() is emitted. For convenience, isValid() returns \c true if the socket is ready for reading and writing, but note that the socket's state must be @@ -113,7 +113,7 @@ QAbstractSocket::UnconnectedState, and emits disconnected(). If you want to abort a connection immediately, discarding all pending data, call abort() instead. If the remote host closes the connection, - QAbstractSocket will emit error(QAbstractSocket::RemoteHostClosedError), + QAbstractSocket will emit errorOccurred(QAbstractSocket::RemoteHostClosedError), during which the socket state will still be ConnectedState, and then the disconnected() signal will be emitted. @@ -203,6 +203,14 @@ /*! \fn void QAbstractSocket::error(QAbstractSocket::SocketError socketError) + \obsolete + + Use errorOccurred() instead. +*/ + +/*! + \fn void QAbstractSocket::errorOccurred(QAbstractSocket::SocketError socketError) + \since 5.15 This signal is emitted after an error occurred. The \a socketError parameter describes the type of error that occurred. @@ -330,6 +338,7 @@ \value UnknownSocketError An unidentified error occurred. \sa QAbstractSocket::error() + \sa QAbstractSocket::errorOccurred() */ /*! @@ -988,7 +997,7 @@ void QAbstractSocketPrivate::startConnectingByName(const QString &host) } state = QAbstractSocket::UnconnectedState; - emit q->error(socketError); + emit q->errorOccurred(socketError); emit q->stateChanged(state); } @@ -1047,7 +1056,7 @@ void QAbstractSocketPrivate::_q_startConnecting(const QHostInfo &hostInfo) state = QAbstractSocket::UnconnectedState; setError(QAbstractSocket::HostNotFoundError, QAbstractSocket::tr("Host not found")); emit q->stateChanged(state); - emit q->error(QAbstractSocket::HostNotFoundError); + emit q->errorOccurred(QAbstractSocket::HostNotFoundError); return; } @@ -1070,8 +1079,8 @@ void QAbstractSocketPrivate::_q_startConnecting(const QHostInfo &hostInfo) _q_testConnection(), this function takes the first address of the pending addresses list and tries to connect to it. If the connection succeeds, QAbstractSocket will emit - connected(). Otherwise, error(ConnectionRefusedError) or - error(SocketTimeoutError) is emitted. + connected(). Otherwise, errorOccurred(ConnectionRefusedError) or + errorOccurred(SocketTimeoutError) is emitted. */ void QAbstractSocketPrivate::_q_connectToNextAddress() { @@ -1101,7 +1110,7 @@ void QAbstractSocketPrivate::_q_connectToNextAddress() // q->setErrorString(QAbstractSocket::tr("Connection refused")); } emit q->stateChanged(state); - emit q->error(socketError); + emit q->errorOccurred(socketError); return; } @@ -1223,7 +1232,7 @@ void QAbstractSocketPrivate::_q_abortConnectionAttempt() setError(QAbstractSocket::SocketTimeoutError, QAbstractSocket::tr("Connection timed out")); emit q->stateChanged(state); - emit q->error(socketError); + emit q->errorOccurred(socketError); } else { _q_connectToNextAddress(); } @@ -1430,14 +1439,14 @@ void QAbstractSocketPrivate::setError(QAbstractSocket::SocketError errorCode, \internal Sets the socket error state to \c errorCode and \a errorString, - and emits the QAbstractSocket::error() signal. + and emits the QAbstractSocket::errorOccurred() signal. */ void QAbstractSocketPrivate::setErrorAndEmit(QAbstractSocket::SocketError errorCode, const QString &errorString) { Q_Q(QAbstractSocket); setError(errorCode, errorString); - emit q->error(errorCode); + emit q->errorOccurred(errorCode); } /*! \internal @@ -1456,6 +1465,9 @@ QAbstractSocket::QAbstractSocket(SocketType socketType, : socketType == SctpSocket ? "Sctp" : "Unknown", &dd, parent); #endif d->socketType = socketType; + + // Support the deprecated error() signal: + connect(this, &QAbstractSocket::errorOccurred, this, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error)); } /*! @@ -1654,7 +1666,7 @@ bool QAbstractSocket::isValid() const established, QAbstractSocket enters ConnectedState and emits connected(). - At any point, the socket can emit error() to signal that an error + At any point, the socket can emit errorOccurred() to signal that an error occurred. \a hostName may be an IP address in string form (e.g., diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h index de09195eeb1..1482dcaab24 100644 --- a/src/network/socket/qabstractsocket.h +++ b/src/network/socket/qabstractsocket.h @@ -206,7 +206,11 @@ Q_SIGNALS: void connected(); void disconnected(); void stateChanged(QAbstractSocket::SocketState); +#if QT_DEPRECATED_SINCE(5,15) + QT_DEPRECATED_X("Use QAbstractSocket::errorOccurred(QAbstractSocket::SocketError) instead") void error(QAbstractSocket::SocketError); +#endif + void errorOccurred(QAbstractSocket::SocketError); #ifndef QT_NO_NETWORKPROXY void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator); #endif diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index bce0da4ae42..9de9b284c1b 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -93,7 +93,7 @@ bool QHttpSocketEngine::initialize(QAbstractSocket::SocketType type, QAbstractSo connect(d->socket, SIGNAL(bytesWritten(qint64)), this, SLOT(slotSocketBytesWritten()), Qt::DirectConnection); - connect(d->socket, SIGNAL(error(QAbstractSocket::SocketError)), + connect(d->socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SLOT(slotSocketError(QAbstractSocket::SocketError)), Qt::DirectConnection); connect(d->socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), diff --git a/src/network/socket/qlocalsocket.h b/src/network/socket/qlocalsocket.h index ae78c86b3c5..9cd62abca64 100644 --- a/src/network/socket/qlocalsocket.h +++ b/src/network/socket/qlocalsocket.h @@ -132,14 +132,14 @@ private: Q_DISABLE_COPY(QLocalSocket) #if defined(QT_LOCALSOCKET_TCP) Q_PRIVATE_SLOT(d_func(), void _q_stateChanged(QAbstractSocket::SocketState)) - Q_PRIVATE_SLOT(d_func(), void _q_error(QAbstractSocket::SocketError)) + Q_PRIVATE_SLOT(d_func(), void _q_errorOccurred(QAbstractSocket::SocketError)) #elif defined(Q_OS_WIN) Q_PRIVATE_SLOT(d_func(), void _q_canWrite()) Q_PRIVATE_SLOT(d_func(), void _q_pipeClosed()) Q_PRIVATE_SLOT(d_func(), void _q_winError(ulong, const QString &)) #else Q_PRIVATE_SLOT(d_func(), void _q_stateChanged(QAbstractSocket::SocketState)) - Q_PRIVATE_SLOT(d_func(), void _q_error(QAbstractSocket::SocketError)) + Q_PRIVATE_SLOT(d_func(), void _q_errorOccurred(QAbstractSocket::SocketError)) Q_PRIVATE_SLOT(d_func(), void _q_connectToSocket()) Q_PRIVATE_SLOT(d_func(), void _q_abortConnectionAttempt()) #endif diff --git a/src/network/socket/qlocalsocket_p.h b/src/network/socket/qlocalsocket_p.h index e3bcd923263..0e05e4c5d75 100644 --- a/src/network/socket/qlocalsocket_p.h +++ b/src/network/socket/qlocalsocket_p.h @@ -127,7 +127,7 @@ public: QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const; void setErrorAndEmit(QLocalSocket::LocalSocketError, const QString &function); void _q_stateChanged(QAbstractSocket::SocketState newState); - void _q_error(QAbstractSocket::SocketError newError); + void _q_errorOccurred(QAbstractSocket::SocketError newError); #elif defined(Q_OS_WIN) ~QLocalSocketPrivate(); void destroyPipeHandles(); @@ -144,7 +144,7 @@ public: QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const; void setErrorAndEmit(QLocalSocket::LocalSocketError, const QString &function); void _q_stateChanged(QAbstractSocket::SocketState newState); - void _q_error(QAbstractSocket::SocketError newError); + void _q_errorOccurred(QAbstractSocket::SocketError newError); void _q_connectToSocket(); void _q_abortConnectionAttempt(); void cancelDelayedConnect(); diff --git a/src/network/socket/qlocalsocket_tcp.cpp b/src/network/socket/qlocalsocket_tcp.cpp index e13bcfc0cb9..1c63d161874 100644 --- a/src/network/socket/qlocalsocket_tcp.cpp +++ b/src/network/socket/qlocalsocket_tcp.cpp @@ -77,8 +77,8 @@ void QLocalSocketPrivate::setSocket(QLocalUnixSocket* socket) q->connect(tcpSocket, SIGNAL(disconnected()), q, SIGNAL(disconnected())); q->connect(tcpSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), q, SLOT(_q_stateChanged(QAbstractSocket::SocketState))); - q->connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), - q, SLOT(_q_error(QAbstractSocket::SocketError))); + q->connect(tcpSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), + q, SLOT(_q_errorOccurred(QAbstractSocket::SocketError))); q->connect(tcpSocket, SIGNAL(readChannelFinished()), q, SIGNAL(readChannelFinished())); tcpSocket->setParent(q); } @@ -88,7 +88,7 @@ qint64 QLocalSocketPrivate::skip(qint64 maxSize) return tcpSocket->skip(maxSize); } -void QLocalSocketPrivate::_q_error(QAbstractSocket::SocketError socketError) +void QLocalSocketPrivate::_q_errorOccurred(QAbstractSocket::SocketError socketError) { Q_Q(QLocalSocket); QString function = QLatin1String("QLocalSocket"); diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index 5e1da78c942..d9b39a7752f 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -81,8 +81,8 @@ void QLocalSocketPrivate::init() q->connect(&unixSocket, SIGNAL(disconnected()), q, SIGNAL(disconnected())); q->connect(&unixSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), q, SLOT(_q_stateChanged(QAbstractSocket::SocketState))); - q->connect(&unixSocket, SIGNAL(error(QAbstractSocket::SocketError)), - q, SLOT(_q_error(QAbstractSocket::SocketError))); + q->connect(&unixSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), + q, SLOT(_q_errorOccurred(QAbstractSocket::SocketError))); q->connect(&unixSocket, SIGNAL(readChannelFinished()), q, SIGNAL(readChannelFinished())); unixSocket.setParent(q); } @@ -92,7 +92,7 @@ qint64 QLocalSocketPrivate::skip(qint64 maxSize) return unixSocket.skip(maxSize); } -void QLocalSocketPrivate::_q_error(QAbstractSocket::SocketError socketError) +void QLocalSocketPrivate::_q_errorOccurred(QAbstractSocket::SocketError socketError) { Q_Q(QLocalSocket); QString function = QLatin1String("QLocalSocket"); diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 0530a1af30c..4f866e4da00 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -559,8 +559,8 @@ void QSocks5SocketEnginePrivate::initialize(Socks5Mode socks5Mode) Qt::DirectConnection); QObject::connect(data->controlSocket, SIGNAL(bytesWritten(qint64)), q, SLOT(_q_controlSocketBytesWritten()), Qt::DirectConnection); - QObject::connect(data->controlSocket, SIGNAL(error(QAbstractSocket::SocketError)), - q, SLOT(_q_controlSocketError(QAbstractSocket::SocketError)), + QObject::connect(data->controlSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), + q, SLOT(_q_controlSocketErrorOccurred(QAbstractSocket::SocketError)), Qt::DirectConnection); QObject::connect(data->controlSocket, SIGNAL(disconnected()), q, SLOT(_q_controlSocketDisconnected()), Qt::DirectConnection); @@ -1056,7 +1056,7 @@ bool QSocks5SocketEngine::initialize(qintptr socketDescriptor, QAbstractSocket:: Qt::DirectConnection); QObject::connect(d->data->controlSocket, SIGNAL(bytesWritten(qint64)), this, SLOT(_q_controlSocketBytesWritten()), Qt::DirectConnection); - QObject::connect(d->data->controlSocket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(_q_controlSocketError(QAbstractSocket::SocketError)), + QObject::connect(d->data->controlSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SLOT(_q_controlSocketErrorOccurred(QAbstractSocket::SocketError)), Qt::DirectConnection); QObject::connect(d->data->controlSocket, SIGNAL(disconnected()), this, SLOT(_q_controlSocketDisconnected()), Qt::DirectConnection); @@ -1231,7 +1231,7 @@ void QSocks5SocketEnginePrivate::_q_controlSocketBytesWritten() } } -void QSocks5SocketEnginePrivate::_q_controlSocketError(QAbstractSocket::SocketError error) +void QSocks5SocketEnginePrivate::_q_controlSocketErrorOccurred(QAbstractSocket::SocketError error) { QSOCKS5_D_DEBUG << "controlSocketError" << error << data->controlSocket->errorString(); diff --git a/src/network/socket/qsocks5socketengine_p.h b/src/network/socket/qsocks5socketengine_p.h index c256987e2de..77b461b9441 100644 --- a/src/network/socket/qsocks5socketengine_p.h +++ b/src/network/socket/qsocks5socketengine_p.h @@ -130,7 +130,7 @@ private: Q_DISABLE_COPY_MOVE(QSocks5SocketEngine) Q_PRIVATE_SLOT(d_func(), void _q_controlSocketConnected()) Q_PRIVATE_SLOT(d_func(), void _q_controlSocketReadNotification()) - Q_PRIVATE_SLOT(d_func(), void _q_controlSocketError(QAbstractSocket::SocketError)) + Q_PRIVATE_SLOT(d_func(), void _q_controlSocketErrorOccurred(QAbstractSocket::SocketError)) #ifndef QT_NO_UDPSOCKET Q_PRIVATE_SLOT(d_func(), void _q_udpSocketReadNotification()) #endif @@ -246,7 +246,7 @@ public: void _q_controlSocketConnected(); void _q_controlSocketReadNotification(); - void _q_controlSocketError(QAbstractSocket::SocketError); + void _q_controlSocketErrorOccurred(QAbstractSocket::SocketError); #ifndef QT_NO_UDPSOCKET void _q_udpSocketReadNotification(); #endif diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 775b6227ed1..912b30b29bb 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -2535,7 +2535,7 @@ void QSslSocketPrivate::createPlainSocket(QIODevice::OpenMode openMode) q->connect(plainSocket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), q, SLOT(_q_stateChangedSlot(QAbstractSocket::SocketState)), Qt::DirectConnection); - q->connect(plainSocket, SIGNAL(error(QAbstractSocket::SocketError)), + q->connect(plainSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), q, SLOT(_q_errorSlot(QAbstractSocket::SocketError)), Qt::DirectConnection); q->connect(plainSocket, SIGNAL(readyRead()), |
