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') 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