From 94b3dd77f29a00ebbd1efdc66d75f57e1c75b152 Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Thu, 9 Jan 2020 11:58:34 +0100 Subject: QAbstractSocket: deprecate 'error' member-function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The one that is a getter for the last error found. This is to disambiguate the expression '&QAbstractSocket::error'. Introduce a new member-function socketError as a replacement. [ChangeLog][Deprecation Notice] QAbstractSocket::error() (the getter) is deprecated; superseded by socketError(). Task-number: QTBUG-80369 Change-Id: Ia2e3d108657aaa7929ab0810babe2ede309740ba Reviewed-by: Mårten Nordheim --- src/network/access/qhttpprotocolhandler.cpp | 2 +- .../access/qnetworkaccessdebugpipebackend.cpp | 4 +-- src/network/socket/qabstractsocket.cpp | 29 ++++++++++++++++++---- src/network/socket/qabstractsocket.h | 7 +++++- src/network/socket/qhttpsocketengine.cpp | 13 +++++----- src/network/socket/qlocalsocket_unix.cpp | 2 +- src/network/socket/qsocks5socketengine.cpp | 22 ++++++++-------- src/network/ssl/qdtls_openssl.cpp | 2 +- src/network/ssl/qsslsocket.cpp | 8 +++--- src/network/ssl/qsslsocket_openssl.cpp | 2 +- src/network/ssl/qsslsocket_schannel.cpp | 4 +-- 11 files changed, 59 insertions(+), 36 deletions(-) (limited to 'src/network') diff --git a/src/network/access/qhttpprotocolhandler.cpp b/src/network/access/qhttpprotocolhandler.cpp index d39589fb96..981effb54f 100644 --- a/src/network/access/qhttpprotocolhandler.cpp +++ b/src/network/access/qhttpprotocolhandler.cpp @@ -233,7 +233,7 @@ void QHttpProtocolHandler::_q_readyRead() char c; qint64 ret = m_socket->peek(&c, 1); if (ret < 0) { - m_channel->_q_error(m_socket->error()); + m_channel->_q_error(m_socket->socketError()); // We still need to handle the reply so it emits its signals etc. if (m_reply) _q_receiveReply(); diff --git a/src/network/access/qnetworkaccessdebugpipebackend.cpp b/src/network/access/qnetworkaccessdebugpipebackend.cpp index 03ffc69628..0406f2fac1 100644 --- a/src/network/access/qnetworkaccessdebugpipebackend.cpp +++ b/src/network/access/qnetworkaccessdebugpipebackend.cpp @@ -242,9 +242,9 @@ void QNetworkAccessDebugPipeBackend::closeDownstreamChannel() void QNetworkAccessDebugPipeBackend::socketError() { - qWarning("QNetworkAccessDebugPipeBackend::socketError() %d",socket.error()); + qWarning("QNetworkAccessDebugPipeBackend::socketError() %d",socket.socketError()); QNetworkReply::NetworkError code; - switch (socket.error()) { + switch (socket.socketError()) { case QAbstractSocket::RemoteHostClosedError: return; // socketDisconnected will be called diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index cbc4114904..0d9e25954d 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -215,7 +215,7 @@ connections, you will have to register it with Q_DECLARE_METATYPE() and qRegisterMetaType(). - \sa error(), errorString(), {Creating Custom Qt Types} + \sa socketError(), errorString(), {Creating Custom Qt Types} */ /*! @@ -329,7 +329,7 @@ is non-blocking). \value UnknownSocketError An unidentified error occurred. - \sa QAbstractSocket::error() + \sa QAbstractSocket::socketError() */ /*! @@ -2094,7 +2094,7 @@ QVariant QAbstractSocket::socketOption(QAbstractSocket::SocketOption option) Waits until the socket is connected, up to \a msecs milliseconds. If the connection has been established, this function returns \c true; otherwise it returns \c false. In the case - where it returns \c false, you can call error() to determine + where it returns \c false, you can call socketError() to determine the cause of the error. The following example waits up to one second for a connection @@ -2873,7 +2873,7 @@ void QAbstractSocket::setReadBufferSize(qint64 size) /*! Returns the state of the socket. - \sa error() + \sa socketError() */ QAbstractSocket::SocketState QAbstractSocket::state() const { @@ -2900,16 +2900,35 @@ QAbstractSocket::SocketType QAbstractSocket::socketType() const return d_func()->socketType; } +#if QT_DEPRECATED_SINCE(5, 15) /*! + \deprecated + + Use socketError() instead. + Returns the type of error that last occurred. - \sa state(), errorString() + \sa state(), errorString(), socketError() */ QAbstractSocket::SocketError QAbstractSocket::error() const +{ + return socketError(); +} +#endif // QT_DEPRECATED_SINCE(5, 15) + +/*! + \since 5.15 + + Returns the type of error that last occurred. + + \sa state(), errorString() +*/ +QAbstractSocket::SocketError QAbstractSocket::socketError() const { return d_func()->socketError; } + /*! Sets the type of error that last occurred to \a socketError. diff --git a/src/network/socket/qabstractsocket.h b/src/network/socket/qabstractsocket.h index de09195eeb..cbc79ea684 100644 --- a/src/network/socket/qabstractsocket.h +++ b/src/network/socket/qabstractsocket.h @@ -180,7 +180,12 @@ public: SocketType socketType() const; SocketState state() const; - SocketError error() const; + +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use socketError()") SocketError error() const; +#endif // QT_DEPRECATED_SINCE(5, 15) + + SocketError socketError() const; // from QIODevice void close() override; diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index 76b3053224..9a26868edc 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -370,8 +370,8 @@ bool QHttpSocketEngine::waitForRead(int msecs, bool *timedOut) if (!d->socket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) { if (d->socket->state() == QAbstractSocket::UnconnectedState) return true; - setError(d->socket->error(), d->socket->errorString()); - if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError) + setError(d->socket->socketError(), d->socket->errorString()); + if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError) *timedOut = true; return false; } @@ -385,8 +385,8 @@ bool QHttpSocketEngine::waitForRead(int msecs, bool *timedOut) // Report any error that may occur. if (d->state != Connected) { - setError(d->socket->error(), d->socket->errorString()); - if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError) + setError(d->socket->socketError(), d->socket->errorString()); + if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError) *timedOut = true; return false; } @@ -401,7 +401,7 @@ bool QHttpSocketEngine::waitForWrite(int msecs, bool *timedOut) if (d->state == Connected) { if (d->socket->bytesToWrite()) { if (!d->socket->waitForBytesWritten(msecs)) { - if (d->socket->error() == QAbstractSocket::SocketTimeoutError && timedOut) + if (d->socket->socketError() == QAbstractSocket::SocketTimeoutError && timedOut) *timedOut = true; return false; } @@ -421,8 +421,7 @@ bool QHttpSocketEngine::waitForWrite(int msecs, bool *timedOut) // Report any error that may occur. if (d->state != Connected) { -// setError(d->socket->error(), d->socket->errorString()); - if (timedOut && d->socket->error() == QAbstractSocket::SocketTimeoutError) + if (timedOut && d->socket->socketError() == QAbstractSocket::SocketTimeoutError) *timedOut = true; } diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index 7de9a7d4c7..55bdd12748 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -464,7 +464,7 @@ void QLocalSocket::disconnectFromServer() QLocalSocket::LocalSocketError QLocalSocket::error() const { Q_D(const QLocalSocket); - switch (d->unixSocket.error()) { + switch (d->unixSocket.socketError()) { case QAbstractSocket::ConnectionRefusedError: return QLocalSocket::ConnectionRefusedError; case QAbstractSocket::RemoteHostClosedError: diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 622d5df131..3bce891ee9 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -594,7 +594,7 @@ void QSocks5SocketEnginePrivate::setErrorState(Socks5State state, const QString case ConnectError: case ControlSocketError: { - QAbstractSocket::SocketError controlSocketError = data->controlSocket->error(); + QAbstractSocket::SocketError controlSocketError = data->controlSocket->socketError(); if (socks5State != Connected) { switch (controlSocketError) { case QAbstractSocket::ConnectionRefusedError: @@ -918,7 +918,7 @@ void QSocks5SocketEnginePrivate::_q_emitPendingReadNotification() return; // check if there needs to be a new zero read notification if (data && data->controlSocket->state() == QAbstractSocket::UnconnectedState - && data->controlSocket->error() == QAbstractSocket::RemoteHostClosedError) { + && data->controlSocket->socketError() == QAbstractSocket::RemoteHostClosedError) { connectData->readBuffer.clear(); emitReadNotification(); } @@ -1256,7 +1256,7 @@ void QSocks5SocketEnginePrivate::_q_controlSocketError(QAbstractSocket::SocketEr data->controlSocket->close(); emitConnectionNotification(); } else { - q_func()->setError(data->controlSocket->error(), data->controlSocket->errorString()); + q_func()->setError(data->controlSocket->socketError(), data->controlSocket->errorString()); emitReadNotification(); emitWriteNotification(); } @@ -1348,7 +1348,7 @@ bool QSocks5SocketEngine::bind(const QHostAddress &addr, quint16 port) if (d->mode == QSocks5SocketEnginePrivate::UdpAssociateMode) { if (!d->udpData->udpSocket->bind(address, port)) { QSOCKS5_Q_DEBUG << "local udp bind failed"; - setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); + setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString()); return false; } d->localAddress = d->udpData->udpSocket->localAddress(); @@ -1656,8 +1656,8 @@ qint64 QSocks5SocketEngine::writeDatagram(const char *data, qint64 len, const QI } if (d->udpData->udpSocket->writeDatagram(sealedBuf, d->udpData->associateAddress, d->udpData->associatePort) != sealedBuf.size()) { //### try frgamenting - if (d->udpData->udpSocket->error() == QAbstractSocket::DatagramTooLargeError) - setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); + if (d->udpData->udpSocket->socketError() == QAbstractSocket::DatagramTooLargeError) + setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString()); //### else maybe more serious error return -1; } @@ -1727,7 +1727,7 @@ bool QSocks5SocketEnginePrivate::waitForConnected(int msecs, bool *timedOut) return true; setErrorState(QSocks5SocketEnginePrivate::ControlSocketError); - if (timedOut && data->controlSocket->error() == QAbstractSocket::SocketTimeoutError) + if (timedOut && data->controlSocket->socketError() == QAbstractSocket::SocketTimeoutError) *timedOut = true; return false; } @@ -1765,8 +1765,8 @@ bool QSocks5SocketEngine::waitForRead(int msecs, bool *timedOut) if (d->data->controlSocket->state() == QAbstractSocket::UnconnectedState) return true; - setError(d->data->controlSocket->error(), d->data->controlSocket->errorString()); - if (timedOut && d->data->controlSocket->error() == QAbstractSocket::SocketTimeoutError) + setError(d->data->controlSocket->socketError(), d->data->controlSocket->errorString()); + if (timedOut && d->data->controlSocket->socketError() == QAbstractSocket::SocketTimeoutError) *timedOut = true; return false; } @@ -1775,8 +1775,8 @@ bool QSocks5SocketEngine::waitForRead(int msecs, bool *timedOut) } else { while (!d->readNotificationActivated) { if (!d->udpData->udpSocket->waitForReadyRead(qt_subtract_from_timeout(msecs, stopWatch.elapsed()))) { - setError(d->udpData->udpSocket->error(), d->udpData->udpSocket->errorString()); - if (timedOut && d->udpData->udpSocket->error() == QAbstractSocket::SocketTimeoutError) + setError(d->udpData->udpSocket->socketError(), d->udpData->udpSocket->errorString()); + if (timedOut && d->udpData->udpSocket->socketError() == QAbstractSocket::SocketTimeoutError) *timedOut = true; return false; } diff --git a/src/network/ssl/qdtls_openssl.cpp b/src/network/ssl/qdtls_openssl.cpp index 25a6c5f49c..36b4d572fd 100644 --- a/src/network/ssl/qdtls_openssl.cpp +++ b/src/network/ssl/qdtls_openssl.cpp @@ -1125,7 +1125,7 @@ qint64 QDtlsPrivateOpenSSL::writeDatagramEncrypted(QUdpSocket *socket, // some errors can be just ignored (it's UDP, not TCP after all). // Unlike QSslSocket we do not abort though. QString description(QSslSocketBackendPrivate::getErrorsFromOpenSsl()); - if (socket->error() != QAbstractSocket::UnknownSocketError && description.isEmpty()) { + if (socket->socketError() != QAbstractSocket::UnknownSocketError && description.isEmpty()) { setDtlsError(QDtlsError::UnderlyingSocketError, socket->errorString()); } else { setDtlsError(QDtlsError::TlsFatalError, diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 1b72be66fe..9286a9a622 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -549,7 +549,7 @@ bool QSslSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState state d->createPlainSocket(openMode); bool retVal = d->plainSocket->setSocketDescriptor(socketDescriptor, state, openMode); d->cachedSocketDescriptor = d->plainSocket->socketDescriptor(); - d->setError(d->plainSocket->error(), d->plainSocket->errorString()); + d->setError(d->plainSocket->socketError(), d->plainSocket->errorString()); setSocketState(state); setOpenMode(openMode); setLocalPort(d->plainSocket->localPort()); @@ -1651,7 +1651,7 @@ bool QSslSocket::waitForConnected(int msecs) bool retVal = d->plainSocket->waitForConnected(msecs); if (!retVal) { setSocketState(d->plainSocket->state()); - d->setError(d->plainSocket->error(), d->plainSocket->errorString()); + d->setError(d->plainSocket->socketError(), d->plainSocket->errorString()); } return retVal; } @@ -1820,7 +1820,7 @@ bool QSslSocket::waitForDisconnected(int msecs) bool retVal = d->plainSocket->waitForDisconnected(qt_subtract_from_timeout(msecs, stopWatch.elapsed())); if (!retVal) { setSocketState(d->plainSocket->state()); - d->setError(d->plainSocket->error(), d->plainSocket->errorString()); + d->setError(d->plainSocket->socketError(), d->plainSocket->errorString()); } return retVal; } @@ -2668,7 +2668,7 @@ void QSslSocketPrivate::_q_errorSlot(QAbstractSocket::SocketError error) readBufferMaxSize = tmpReadBufferMaxSize; } - setErrorAndEmit(plainSocket->error(), plainSocket->errorString()); + setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString()); } /*! diff --git a/src/network/ssl/qsslsocket_openssl.cpp b/src/network/ssl/qsslsocket_openssl.cpp index 8fbbffcaca..41f933b299 100644 --- a/src/network/ssl/qsslsocket_openssl.cpp +++ b/src/network/ssl/qsslsocket_openssl.cpp @@ -993,7 +993,7 @@ void QSslSocketBackendPrivate::transmit() if (actualWritten < 0) { //plain socket write fails if it was in the pending close state. const ScopedBool bg(inSetAndEmitError, true); - setErrorAndEmit(plainSocket->error(), plainSocket->errorString()); + setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString()); return; } transmitting = true; diff --git a/src/network/ssl/qsslsocket_schannel.cpp b/src/network/ssl/qsslsocket_schannel.cpp index 31b0db4818..f9586b7862 100644 --- a/src/network/ssl/qsslsocket_schannel.cpp +++ b/src/network/ssl/qsslsocket_schannel.cpp @@ -582,7 +582,7 @@ bool QSslSocketBackendPrivate::sendToken(void *token, unsigned long tokenLength, if (written != qint64(tokenLength)) { // Failed to write/buffer everything or an error occurred if (emitError) - setErrorAndEmit(plainSocket->error(), plainSocket->errorString()); + setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString()); return false; } return true; @@ -1292,7 +1292,7 @@ void QSslSocketBackendPrivate::transmit() if (bytesWritten >= 0) { totalBytesWritten += bytesWritten; } else { - setErrorAndEmit(plainSocket->error(), plainSocket->errorString()); + setErrorAndEmit(plainSocket->socketError(), plainSocket->errorString()); return; } } -- cgit v1.2.3 From 0de6c26ac17c90f513329fdbe87ef036fc25925a Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Tue, 7 Jan 2020 13:32:02 +0100 Subject: QLocalSocket - deprecate ambiguous 'error' overloads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit QLocalSocket::error is overloaded as a signal and an accessor (for the error reported by the signal). This means connecting to the signal using a pointer to member function would require ambiguity resolution. We deprecate the old accessor (to be removed in Qt 6) and introduce a new one - 'socketError'. [ChangeLog][Deprecation Notice] QLocalSocket::error() (the getter) is deprecated; superseded by socketError(). Task-number: QTBUG-80369 Change-Id: Iab346f7b4cd1024dee9e5ef71b4b7e09f6d95b12 Reviewed-by: Mårten Nordheim --- src/network/socket/qlocalsocket.cpp | 24 +++++++++++++++++++----- src/network/socket/qlocalsocket.h | 7 ++++++- src/network/socket/qlocalsocket_tcp.cpp | 7 +++++++ src/network/socket/qlocalsocket_unix.cpp | 7 +++++++ src/network/socket/qlocalsocket_win.cpp | 7 +++++++ 5 files changed, 46 insertions(+), 6 deletions(-) (limited to 'src/network') diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp index d35f838af5..d517f91aad 100644 --- a/src/network/socket/qlocalsocket.cpp +++ b/src/network/socket/qlocalsocket.cpp @@ -220,11 +220,25 @@ QT_BEGIN_NAMESPACE /*! \fn QLocalSocket::LocalSocketError QLocalSocket::error() const + \deprecated + + Use socketError() instead. + + Returns the type of error that last occurred. + + \sa state(), errorString(), socketError() +*/ + +/*! + \fn QLocalSocket::LocalSocketError QLocalSocket::socketError() const + \since 5.15 + Returns the type of error that last occurred. \sa state(), errorString() */ + /*! \fn bool QLocalSocket::isValid() const @@ -272,7 +286,7 @@ QT_BEGIN_NAMESPACE Waits until the socket is connected, up to \a msecs milliseconds. If the connection has been established, this function returns \c true; otherwise it returns \c false. In the case where it returns \c false, you can call - error() to determine the cause of the error. + socketError() to determine the cause of the error. The following example waits up to one second for a connection to be established: @@ -291,7 +305,7 @@ QT_BEGIN_NAMESPACE connection was successfully disconnected, this function returns \c true; otherwise it returns \c false (if the operation timed out, if an error occurred, or if this QLocalSocket is already disconnected). In the case - where it returns \c false, you can call error() to determine the cause of + where it returns \c false, you can call socketError() to determine the cause of the error. The following example waits up to one second for a connection @@ -337,7 +351,7 @@ QT_BEGIN_NAMESPACE connections, you will have to register it with Q_DECLARE_METATYPE() and qRegisterMetaType(). - \sa error(), errorString(), {Creating Custom Qt Types} + \sa socketError(), errorString(), {Creating Custom Qt Types} */ /*! @@ -446,7 +460,7 @@ QString QLocalSocket::fullServerName() const /*! Returns the state of the socket. - \sa error() + \sa socketError() */ QLocalSocket::LocalSocketState QLocalSocket::state() const { @@ -466,7 +480,7 @@ bool QLocalSocket::isSequential() const The LocalServerError enumeration represents the errors that can occur. The most recent error can be retrieved through a call to - \l QLocalSocket::error(). + \l QLocalSocket::socketError(). \value ConnectionRefusedError The connection was refused by the peer (or timed out). diff --git a/src/network/socket/qlocalsocket.h b/src/network/socket/qlocalsocket.h index 1876a6ac0d..9cf76d1022 100644 --- a/src/network/socket/qlocalsocket.h +++ b/src/network/socket/qlocalsocket.h @@ -97,7 +97,12 @@ public: virtual bool canReadLine() const override; virtual bool open(OpenMode openMode = ReadWrite) override; virtual void close() override; - LocalSocketError error() const; + +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use socketError()") LocalSocketError error() const; +#endif // QT_DEPRECATED_SINCE(5, 15) + + LocalSocketError socketError() const; bool flush(); bool isValid() const; qint64 readBufferSize() const; diff --git a/src/network/socket/qlocalsocket_tcp.cpp b/src/network/socket/qlocalsocket_tcp.cpp index 41e5b47627..74d3d547b9 100644 --- a/src/network/socket/qlocalsocket_tcp.cpp +++ b/src/network/socket/qlocalsocket_tcp.cpp @@ -363,7 +363,14 @@ void QLocalSocket::disconnectFromServer() d->tcpSocket->disconnectFromHost(); } +#if QT_DEPRECATED_SINCE(5, 15) QLocalSocket::LocalSocketError QLocalSocket::error() const +{ + return socketError(); +} +#endif // QT_DEPRECATED_SINCE(5, 15) + +QLocalSocket::LocalSocketError QLocalSocket::socketError() const { Q_D(const QLocalSocket); switch (d->tcpSocket->error()) { diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index 55bdd12748..2e2eb7dee9 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -461,7 +461,14 @@ void QLocalSocket::disconnectFromServer() d->unixSocket.disconnectFromHost(); } +#if QT_DEPRECATED_SINCE(5, 15) QLocalSocket::LocalSocketError QLocalSocket::error() const +{ + return socketError(); +} +#endif // QT_DEPRECATED_SINCE(5, 15) + +QLocalSocket::LocalSocketError QLocalSocket::socketError() const { Q_D(const QLocalSocket); switch (d->unixSocket.socketError()) { diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 4decbd5ded..657790519b 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -330,7 +330,14 @@ void QLocalSocket::disconnectFromServer() } } +#if QT_DEPRECATED_SINCE(5, 15) QLocalSocket::LocalSocketError QLocalSocket::error() const +{ + return socketError(); +} +#endif // QT_DEPRECATED_SINCE(5, 15) + +QLocalSocket::LocalSocketError QLocalSocket::socketError() const { Q_D(const QLocalSocket); return d->error; -- cgit v1.2.3 From 76c4c5d5581b2cd36a043234eb167dd55041301d Mon Sep 17 00:00:00 2001 From: Timur Pocheptsov Date: Fri, 10 Jan 2020 11:32:40 +0100 Subject: QSslSocket: deprecate sslErrors() getter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To disambiguate &QSslSocket::sslErrors() expression. Add a new getter - sslHandshakeErrors(). [ChangeLog][Deprecation Notice] QSslSocket::sslErrors() (the getter) was deprecated and superseded by sslHandshakeErrors() Task-number: QTBUG-80369 Change-Id: I9dcca3c8499800c122db230753dc19b07654f8a2 Reviewed-by: Mårten Nordheim --- src/network/ssl/qsslsocket.cpp | 27 ++++++++++++++++++++++++--- src/network/ssl/qsslsocket.h | 5 ++++- 2 files changed, 28 insertions(+), 4 deletions(-) (limited to 'src/network') diff --git a/src/network/ssl/qsslsocket.cpp b/src/network/ssl/qsslsocket.cpp index 9286a9a622..cf971a30bf 100644 --- a/src/network/ssl/qsslsocket.cpp +++ b/src/network/ssl/qsslsocket.cpp @@ -289,7 +289,7 @@ If you want to continue connecting despite the errors that have occurred, you must call QSslSocket::ignoreSslErrors() from inside a slot connected to this signal. If you need to access the error list at a later point, you - can call sslErrors() (without arguments). + can call sslHandshakeErrors(). \a errors contains one or more errors that prevent QSslSocket from verifying the identity of the peer. @@ -1825,15 +1825,36 @@ bool QSslSocket::waitForDisconnected(int msecs) return retVal; } +#if QT_DEPRECATED_SINCE(5, 15) /*! + \deprecated + + Use sslHandshakeErrors() instead. + Returns a list of the last SSL errors that occurred. This is the same list as QSslSocket passes via the sslErrors() signal. If the connection has been encrypted with no errors, this function will return an empty list. - \sa connectToHostEncrypted() + \sa connectToHostEncrypted(), sslHandshakeErrors() */ QList QSslSocket::sslErrors() const +{ + return sslHandshakeErrors(); +} +#endif // QT_DEPRECATED_SINCE(5, 15) + +/*! + \since 5.15 + + Returns a list of the last SSL errors that occurred. This is the + same list as QSslSocket passes via the sslErrors() signal. If the + connection has been encrypted with no errors, this function will + return an empty list. + + \sa connectToHostEncrypted() +*/ +QList QSslSocket::sslHandshakeErrors() const { Q_D(const QSslSocket); return d->sslErrors; @@ -2035,7 +2056,7 @@ void QSslSocket::ignoreSslErrors() You can clear the list of errors you want to ignore by calling this function with an empty list. - \sa sslErrors() + \sa sslErrors(), sslHandshakeErrors() */ void QSslSocket::ignoreSslErrors(const QList &errors) { diff --git a/src/network/ssl/qsslsocket.h b/src/network/ssl/qsslsocket.h index 843e2d15f5..2c3b876c49 100644 --- a/src/network/ssl/qsslsocket.h +++ b/src/network/ssl/qsslsocket.h @@ -192,7 +192,10 @@ public: bool waitForBytesWritten(int msecs = 30000) override; bool waitForDisconnected(int msecs = 30000) override; - QList sslErrors() const; +#if QT_DEPRECATED_SINCE(5, 15) + QT_DEPRECATED_X("Use sslHandshakeErrors()") QList sslErrors() const; +#endif // QT_DEPRECATED_SINCE(5, 15) + QList sslHandshakeErrors() const; static bool supportsSsl(); static long sslLibraryVersionNumber(); -- cgit v1.2.3