From 7321a2c624d1a3bdc0825cf3d09a51643fe83d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Mon, 27 Jan 2020 16:34:53 +0100 Subject: QNetworkAccessManager: deprecate bearer related functions In Qt6 QNAM will no longer use bearer in any way so we deprecate it now. Also mark bearermanagement-conditioned sections for removal in Qt6, the _q_networksession property is part of how QNAM passes the QNetworkSession around. Task-number: QTBUG-81609 Change-Id: I04aad9dd96482c6822dffba1b9af7aa58961149c Reviewed-by: Timur Pocheptsov --- src/network/socket/qabstractsocket.cpp | 13 ++++++++----- src/network/socket/qhttpsocketengine.cpp | 2 +- src/network/socket/qsocks5socketengine.cpp | 4 ++-- src/network/socket/qtcpserver.cpp | 4 ++-- 4 files changed, 13 insertions(+), 10 deletions(-) (limited to 'src/network/socket') diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp index b8957ce818..3d88c0337d 100644 --- a/src/network/socket/qabstractsocket.cpp +++ b/src/network/socket/qabstractsocket.cpp @@ -464,7 +464,10 @@ #include "qabstractsocket_p.h" #include "private/qhostinfo_p.h" +#if QT_CONFIG(bearermanagement) // ### Qt6: Remove section #include "private/qnetworksession_p.h" +#endif +#include "private/qnetworkconfiguration_p.h" // ### Qt6: Remove include #include #include @@ -643,7 +646,7 @@ bool QAbstractSocketPrivate::initSocketLayer(QAbstractSocket::NetworkLayerProtoc QAbstractSocket::tr("Operation on socket is not supported")); return false; } -#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_BEARERMANAGEMENT // ### Qt6: Remove section //copy network session down to the socket engine (if it has been set) socketEngine->setProperty("_q_networksession", q->property("_q_networksession")); #endif @@ -1146,7 +1149,7 @@ void QAbstractSocketPrivate::_q_connectToNextAddress() Qt::DirectConnection); } int connectTimeout = QNetworkConfigurationPrivate::DefaultTimeout; -#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_BEARERMANAGEMENT // ### Qt6: Remove section QSharedPointer networkSession = qvariant_cast< QSharedPointer >(q->property("_q_networksession")); if (networkSession) { QNetworkConfiguration networkConfiguration = networkSession->configuration(); @@ -1941,7 +1944,7 @@ bool QAbstractSocket::setSocketDescriptor(qintptr socketDescriptor, SocketState d->setError(UnsupportedSocketOperationError, tr("Operation on socket is not supported")); return false; } -#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_BEARERMANAGEMENT // ### Qt6: Remove section //copy network session down to the socket engine (if it has been set) d->socketEngine->setProperty("_q_networksession", property("_q_networksession")); #endif @@ -2134,7 +2137,7 @@ bool QAbstractSocket::waitForConnected(int msecs) QElapsedTimer stopWatch; stopWatch.start(); -#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_BEARERMANAGEMENT // ### Qt6: Remove section QSharedPointer networkSession = qvariant_cast< QSharedPointer >(property("_q_networksession")); #endif @@ -2157,7 +2160,7 @@ bool QAbstractSocket::waitForConnected(int msecs) return false; // connect not im progress anymore! int connectTimeout = QNetworkConfigurationPrivate::DefaultTimeout; -#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_BEARERMANAGEMENT // ### Qt6: Remove section if (networkSession) { QNetworkConfiguration networkConfiguration = networkSession->configuration(); connectTimeout = networkConfiguration.connectTimeout(); diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp index 9a26868edc..21f97be29a 100644 --- a/src/network/socket/qhttpsocketengine.cpp +++ b/src/network/socket/qhttpsocketengine.cpp @@ -72,7 +72,7 @@ bool QHttpSocketEngine::initialize(QAbstractSocket::SocketType type, QAbstractSo setSocketType(type); d->socket = new QTcpSocket(this); d->reply = new QHttpNetworkReply(QUrl(), this); -#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_BEARERMANAGEMENT // ### Qt6: Remove section d->socket->setProperty("_q_networkSession", property("_q_networkSession")); #endif diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 3bce891ee9..f0ccc9054a 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -535,7 +535,7 @@ void QSocks5SocketEnginePrivate::initialize(Socks5Mode socks5Mode) udpData = new QSocks5UdpAssociateData; data = udpData; udpData->udpSocket = new QUdpSocket(q); -#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_BEARERMANAGEMENT // ### Qt6: Remove section udpData->udpSocket->setProperty("_q_networksession", q->property("_q_networksession")); #endif udpData->udpSocket->setProxy(QNetworkProxy::NoProxy); @@ -549,7 +549,7 @@ void QSocks5SocketEnginePrivate::initialize(Socks5Mode socks5Mode) } data->controlSocket = new QTcpSocket(q); -#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_BEARERMANAGEMENT // ### Qt6: Remove section data->controlSocket->setProperty("_q_networksession", q->property("_q_networksession")); #endif data->controlSocket->setProxy(QNetworkProxy::NoProxy); diff --git a/src/network/socket/qtcpserver.cpp b/src/network/socket/qtcpserver.cpp index 9916c75e65..c23b143de3 100644 --- a/src/network/socket/qtcpserver.cpp +++ b/src/network/socket/qtcpserver.cpp @@ -314,7 +314,7 @@ bool QTcpServer::listen(const QHostAddress &address, quint16 port) d->serverSocketErrorString = tr("Operation on socket is not supported"); return false; } -#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_BEARERMANAGEMENT // ### Qt6: Remove section //copy network session down to the socket engine (if it has been set) d->socketEngine->setProperty("_q_networksession", property("_q_networksession")); #endif @@ -436,7 +436,7 @@ bool QTcpServer::setSocketDescriptor(qintptr socketDescriptor) d->serverSocketErrorString = tr("Operation on socket is not supported"); return false; } -#ifndef QT_NO_BEARERMANAGEMENT +#ifndef QT_NO_BEARERMANAGEMENT // ### Qt6: Remove section //copy network session down to the socket engine (if it has been set) d->socketEngine->setProperty("_q_networksession", property("_q_networksession")); #endif -- cgit v1.2.3 From c034f92fc2e377f47a0f45efeb66905a0f45d0ae Mon Sep 17 00:00:00 2001 From: Alexander Akulich Date: Fri, 7 Feb 2020 16:31:55 +0300 Subject: Revert "QLocalSocket - deprecate ambiguous 'error' overloads" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 0de6c26ac17c90f513329fdbe87ef036fc25925a. The patch fixes ambiguity between a getter and a signal by changing the getter name, but we still have to rename the signal to follow the signals naming convention. Revert the commit to keep the getter as is and change the signal name instead. Change-Id: I67dbb5cada25da473bdd02e71b1e2d9bd03f039e 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, 6 insertions(+), 46 deletions(-) (limited to 'src/network/socket') diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp index d517f91aad..d35f838af5 100644 --- a/src/network/socket/qlocalsocket.cpp +++ b/src/network/socket/qlocalsocket.cpp @@ -220,25 +220,11 @@ 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 @@ -286,7 +272,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 - socketError() to determine the cause of the error. + error() to determine the cause of the error. The following example waits up to one second for a connection to be established: @@ -305,7 +291,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 socketError() to determine the cause of + where it returns \c false, you can call error() to determine the cause of the error. The following example waits up to one second for a connection @@ -351,7 +337,7 @@ QT_BEGIN_NAMESPACE connections, you will have to register it with Q_DECLARE_METATYPE() and qRegisterMetaType(). - \sa socketError(), errorString(), {Creating Custom Qt Types} + \sa error(), errorString(), {Creating Custom Qt Types} */ /*! @@ -460,7 +446,7 @@ QString QLocalSocket::fullServerName() const /*! Returns the state of the socket. - \sa socketError() + \sa error() */ QLocalSocket::LocalSocketState QLocalSocket::state() const { @@ -480,7 +466,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::socketError(). + \l QLocalSocket::error(). \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 9cf76d1022..1876a6ac0d 100644 --- a/src/network/socket/qlocalsocket.h +++ b/src/network/socket/qlocalsocket.h @@ -97,12 +97,7 @@ public: virtual bool canReadLine() const override; virtual bool open(OpenMode openMode = ReadWrite) override; virtual void close() override; - -#if QT_DEPRECATED_SINCE(5, 15) - QT_DEPRECATED_X("Use socketError()") LocalSocketError error() const; -#endif // QT_DEPRECATED_SINCE(5, 15) - - LocalSocketError socketError() const; + LocalSocketError error() 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 74d3d547b9..41e5b47627 100644 --- a/src/network/socket/qlocalsocket_tcp.cpp +++ b/src/network/socket/qlocalsocket_tcp.cpp @@ -363,14 +363,7 @@ 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 2e2eb7dee9..55bdd12748 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -461,14 +461,7 @@ 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 657790519b..4decbd5ded 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -330,14 +330,7 @@ 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 1c573ba47c338f8f054e1a861d9298b5b2a53cec Mon Sep 17 00:00:00 2001 From: Alexander Akulich Date: Fri, 7 Feb 2020 15:53:04 +0300 Subject: QLocalSocket: Rename private errorOccurred method to setErrorAndEmit() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The method named like a signal and can lead to confusion especially if such a signal will be added. The new name taken from QAbstractSocketPrivate::setErrorAndEmit(), though in QLocalSocket the method is NOT the only place of the error set and the signal emission. Change-Id: I7cdc487a39ec290203cced7359527f888342a0ad Reviewed-by: Mårten Nordheim --- src/network/socket/qlocalsocket_p.h | 4 ++-- src/network/socket/qlocalsocket_tcp.cpp | 10 +++++----- src/network/socket/qlocalsocket_unix.cpp | 28 ++++++++++++++-------------- 3 files changed, 21 insertions(+), 21 deletions(-) (limited to 'src/network/socket') diff --git a/src/network/socket/qlocalsocket_p.h b/src/network/socket/qlocalsocket_p.h index d93b53be0c..e3bcd92326 100644 --- a/src/network/socket/qlocalsocket_p.h +++ b/src/network/socket/qlocalsocket_p.h @@ -125,7 +125,7 @@ public: bool ownsTcpSocket; void setSocket(QLocalUnixSocket*); QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const; - void errorOccurred(QLocalSocket::LocalSocketError, const QString &function); + void setErrorAndEmit(QLocalSocket::LocalSocketError, const QString &function); void _q_stateChanged(QAbstractSocket::SocketState newState); void _q_error(QAbstractSocket::SocketError newError); #elif defined(Q_OS_WIN) @@ -142,7 +142,7 @@ public: qint64 skip(qint64 maxSize) override; QLocalUnixSocket unixSocket; QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const; - void errorOccurred(QLocalSocket::LocalSocketError, const QString &function); + void setErrorAndEmit(QLocalSocket::LocalSocketError, const QString &function); void _q_stateChanged(QAbstractSocket::SocketState newState); void _q_error(QAbstractSocket::SocketError newError); void _q_connectToSocket(); diff --git a/src/network/socket/qlocalsocket_tcp.cpp b/src/network/socket/qlocalsocket_tcp.cpp index 41e5b47627..b60fb74faf 100644 --- a/src/network/socket/qlocalsocket_tcp.cpp +++ b/src/network/socket/qlocalsocket_tcp.cpp @@ -168,7 +168,7 @@ QString QLocalSocketPrivate::generateErrorString(QLocalSocket::LocalSocketError return errorString; } -void QLocalSocketPrivate::errorOccurred(QLocalSocket::LocalSocketError error, const QString &function) +void QLocalSocketPrivate::setErrorAndEmit(QLocalSocket::LocalSocketError error, const QString &function) { Q_Q(QLocalSocket); switch (error) { @@ -231,8 +231,8 @@ void QLocalSocket::connectToServer(OpenMode openMode) emit stateChanged(d->state); if (d->serverName.isEmpty()) { - d->errorOccurred(ServerNotFoundError, - QLatin1String("QLocalSocket::connectToServer")); + d->setErrorAndEmit(ServerNotFoundError, + QLatin1String("QLocalSocket::connectToServer")); return; } @@ -246,8 +246,8 @@ void QLocalSocket::connectToServer(OpenMode openMode) bool ok; const quint16 port = settings.value(d->fullServerName).toUInt(&ok); if (!ok) { - d->errorOccurred(ServerNotFoundError, - QLatin1String("QLocalSocket::connectToServer")); + d->setErrorAndEmit(ServerNotFoundError, + QLatin1String("QLocalSocket::connectToServer")); return; } QIODevice::open(openMode); diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index 55bdd12748..74819f697b 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -172,7 +172,7 @@ QString QLocalSocketPrivate::generateErrorString(QLocalSocket::LocalSocketError return errorString; } -void QLocalSocketPrivate::errorOccurred(QLocalSocket::LocalSocketError error, const QString &function) +void QLocalSocketPrivate::setErrorAndEmit(QLocalSocket::LocalSocketError error, const QString &function) { Q_Q(QLocalSocket); switch (error) { @@ -237,15 +237,15 @@ void QLocalSocket::connectToServer(OpenMode openMode) emit stateChanged(d->state); if (d->serverName.isEmpty()) { - d->errorOccurred(ServerNotFoundError, - QLatin1String("QLocalSocket::connectToServer")); + d->setErrorAndEmit(ServerNotFoundError, + QLatin1String("QLocalSocket::connectToServer")); return; } // create the socket if (-1 == (d->connectingSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, 0, O_NONBLOCK))) { - d->errorOccurred(UnsupportedSocketOperationError, - QLatin1String("QLocalSocket::connectToServer")); + d->setErrorAndEmit(UnsupportedSocketOperationError, + QLatin1String("QLocalSocket::connectToServer")); return; } @@ -281,7 +281,7 @@ void QLocalSocketPrivate::_q_connectToSocket() name.sun_family = PF_UNIX; if (sizeof(name.sun_path) < (uint)encodedConnectingPathName.size() + 1) { QString function = QLatin1String("QLocalSocket::connectToServer"); - errorOccurred(QLocalSocket::ServerNotFoundError, function); + setErrorAndEmit(QLocalSocket::ServerNotFoundError, function); return; } ::memcpy(name.sun_path, encodedConnectingPathName.constData(), @@ -292,17 +292,17 @@ void QLocalSocketPrivate::_q_connectToSocket() { case EINVAL: case ECONNREFUSED: - errorOccurred(QLocalSocket::ConnectionRefusedError, function); + setErrorAndEmit(QLocalSocket::ConnectionRefusedError, function); break; case ENOENT: - errorOccurred(QLocalSocket::ServerNotFoundError, function); + setErrorAndEmit(QLocalSocket::ServerNotFoundError, function); break; case EACCES: case EPERM: - errorOccurred(QLocalSocket::SocketAccessError, function); + setErrorAndEmit(QLocalSocket::SocketAccessError, function); break; case ETIMEDOUT: - errorOccurred(QLocalSocket::SocketTimeoutError, function); + setErrorAndEmit(QLocalSocket::SocketTimeoutError, function); break; case EAGAIN: // Try again later, all of the sockets listening are full @@ -320,7 +320,7 @@ void QLocalSocketPrivate::_q_connectToSocket() delayConnect->setEnabled(true); break; default: - errorOccurred(QLocalSocket::UnknownSocketError, function); + setErrorAndEmit(QLocalSocket::UnknownSocketError, function); } return; } @@ -336,7 +336,7 @@ void QLocalSocketPrivate::_q_connectToSocket() q->emit connected(); } else { QString function = QLatin1String("QLocalSocket::connectToServer"); - errorOccurred(QLocalSocket::UnknownSocketError, function); + setErrorAndEmit(QLocalSocket::UnknownSocketError, function); } connectingSocket = -1; connectingName.clear(); @@ -529,8 +529,8 @@ bool QLocalSocket::waitForConnected(int msec) const int result = qt_poll_msecs(&pfd, 1, timeout); if (result == -1) - d->errorOccurred(QLocalSocket::UnknownSocketError, - QLatin1String("QLocalSocket::waitForConnected")); + d->setErrorAndEmit(QLocalSocket::UnknownSocketError, + QLatin1String("QLocalSocket::waitForConnected")); else if (result > 0) d->_q_connectToSocket(); } while (state() == ConnectingState && !timer.hasExpired(msec)); -- cgit v1.2.3 From c08b0cec2f3acc29e86beba4b1de26caf04bebfd Mon Sep 17 00:00:00 2001 From: Alexander Akulich Date: Fri, 7 Feb 2020 16:12:27 +0300 Subject: QLocalSocket: Deprecate 'error' signal, use 'errorOccurred' instead MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [ChangeLog][Deprecation Notice] QLocalSocket::error() (the signal) is deprecated; superseded by errorOccurred() Change-Id: I579c07564f5c470cf2867864755e0a26e6afce3b Reviewed-by: Mårten Nordheim --- src/network/socket/qlocalsocket.cpp | 17 ++++++++++++++--- src/network/socket/qlocalsocket.h | 4 ++++ src/network/socket/qlocalsocket_tcp.cpp | 6 +++--- src/network/socket/qlocalsocket_unix.cpp | 6 +++--- src/network/socket/qlocalsocket_win.cpp | 6 +++--- 5 files changed, 27 insertions(+), 12 deletions(-) (limited to 'src/network/socket') diff --git a/src/network/socket/qlocalsocket.cpp b/src/network/socket/qlocalsocket.cpp index d35f838af5..38e47d6e26 100644 --- a/src/network/socket/qlocalsocket.cpp +++ b/src/network/socket/qlocalsocket.cpp @@ -74,7 +74,7 @@ QT_BEGIN_NAMESPACE The socket is opened in the given \a openMode and first enters ConnectingState. If a connection is established, QLocalSocket enters ConnectedState and emits connected(). - After calling this function, the socket can emit error() to signal that an error occurred. + After calling this function, the socket can emit errorOccurred() to signal that an error occurred. \sa state(), serverName(), waitForConnected() */ @@ -87,7 +87,7 @@ QT_BEGIN_NAMESPACE Note that unlike in most other QIODevice subclasses, open() may not open the device directly. The function return false if the socket was already connected or if the server to connect - to was not defined and true in any other case. The connected() or error() signals will be + to was not defined and true in any other case. The connected() or errorOccurred() signals will be emitted once the device is actualy open (or the connection failed). See connectToServer() for more details. @@ -329,6 +329,14 @@ QT_BEGIN_NAMESPACE /*! \fn void QLocalSocket::error(QLocalSocket::LocalSocketError socketError) + \obsolete + + Use errorOccurred() instead. +*/ + +/*! + \fn void QLocalSocket::errorOccurred(QLocalSocket::LocalSocketError socketError) + \since 5.15 This signal is emitted after an error occurred. The \a socketError parameter describes the type of error that occurred. @@ -362,6 +370,9 @@ QLocalSocket::QLocalSocket(QObject * parent) { Q_D(QLocalSocket); d->init(); + + // Support the deprecated error() signal: + connect(this, &QLocalSocket::errorOccurred, this, QOverload::of(&QLocalSocket::error)); } /*! @@ -389,7 +400,7 @@ bool QLocalSocket::open(OpenMode openMode) The socket is opened in the given \a openMode and first enters ConnectingState. If a connection is established, QLocalSocket enters ConnectedState and emits connected(). - After calling this function, the socket can emit error() to signal that an error occurred. + After calling this function, the socket can emit errorOccurred() to signal that an error occurred. \sa state(), serverName(), waitForConnected() */ diff --git a/src/network/socket/qlocalsocket.h b/src/network/socket/qlocalsocket.h index 1876a6ac0d..ae78c86b3c 100644 --- a/src/network/socket/qlocalsocket.h +++ b/src/network/socket/qlocalsocket.h @@ -117,7 +117,11 @@ public: Q_SIGNALS: void connected(); void disconnected(); +#if QT_DEPRECATED_SINCE(5,15) + QT_DEPRECATED_X("Use QLocalSocket::errorOccurred(QLocalSocket::LocalSocketError) instead") void error(QLocalSocket::LocalSocketError socketError); +#endif + void errorOccurred(QLocalSocket::LocalSocketError socketError); void stateChanged(QLocalSocket::LocalSocketState socketState); protected: diff --git a/src/network/socket/qlocalsocket_tcp.cpp b/src/network/socket/qlocalsocket_tcp.cpp index b60fb74faf..e13bcfc0cb 100644 --- a/src/network/socket/qlocalsocket_tcp.cpp +++ b/src/network/socket/qlocalsocket_tcp.cpp @@ -95,7 +95,7 @@ void QLocalSocketPrivate::_q_error(QAbstractSocket::SocketError socketError) QLocalSocket::LocalSocketError error = (QLocalSocket::LocalSocketError)socketError; QString errorString = generateErrorString(error, function); q->setErrorString(errorString); - emit q->error(error); + emit q->errorOccurred(error); } void QLocalSocketPrivate::_q_stateChanged(QAbstractSocket::SocketState newState) @@ -206,7 +206,7 @@ void QLocalSocketPrivate::setErrorAndEmit(QLocalSocket::LocalSocketError error, QString errorString = generateErrorString(error, function); q->setErrorString(errorString); - emit q->error(error); + emit q->errorOccurred(error); // errors cause a disconnect tcpSocket->setSocketState(QAbstractSocket::UnconnectedState); @@ -222,7 +222,7 @@ void QLocalSocket::connectToServer(OpenMode openMode) Q_D(QLocalSocket); if (state() == ConnectedState || state() == ConnectingState) { setErrorString(tr("Trying to connect while connection is in progress")); - emit error(QLocalSocket::OperationError); + emit errorOccurred(QLocalSocket::OperationError); return; } diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp index 74819f697b..e860b880d5 100644 --- a/src/network/socket/qlocalsocket_unix.cpp +++ b/src/network/socket/qlocalsocket_unix.cpp @@ -99,7 +99,7 @@ void QLocalSocketPrivate::_q_error(QAbstractSocket::SocketError socketError) QLocalSocket::LocalSocketError error = (QLocalSocket::LocalSocketError)socketError; QString errorString = generateErrorString(error, function); q->setErrorString(errorString); - emit q->error(error); + emit q->errorOccurred(error); } void QLocalSocketPrivate::_q_stateChanged(QAbstractSocket::SocketState newState) @@ -210,7 +210,7 @@ void QLocalSocketPrivate::setErrorAndEmit(QLocalSocket::LocalSocketError error, QString errorString = generateErrorString(error, function); q->setErrorString(errorString); - emit q->error(error); + emit q->errorOccurred(error); // errors cause a disconnect unixSocket.setSocketState(QAbstractSocket::UnconnectedState); @@ -227,7 +227,7 @@ void QLocalSocket::connectToServer(OpenMode openMode) if (state() == ConnectedState || state() == ConnectingState) { QString errorString = d->generateErrorString(QLocalSocket::OperationError, QLatin1String("QLocalSocket::connectToserver")); setErrorString(errorString); - emit error(QLocalSocket::OperationError); + emit errorOccurred(QLocalSocket::OperationError); return; } diff --git a/src/network/socket/qlocalsocket_win.cpp b/src/network/socket/qlocalsocket_win.cpp index 4decbd5ded..48ffd87beb 100644 --- a/src/network/socket/qlocalsocket_win.cpp +++ b/src/network/socket/qlocalsocket_win.cpp @@ -91,7 +91,7 @@ void QLocalSocketPrivate::_q_winError(ulong windowsError, const QString &functio if (state == QLocalSocket::UnconnectedState && currentState != QLocalSocket::ConnectingState) emit q->disconnected(); } - emit q->error(error); + emit q->errorOccurred(error); } QLocalSocketPrivate::QLocalSocketPrivate() : QIODevicePrivate(), @@ -123,7 +123,7 @@ void QLocalSocket::connectToServer(OpenMode openMode) if (state() == ConnectedState || state() == ConnectingState) { d->error = OperationError; d->errorString = tr("Trying to connect while connection is in progress"); - emit error(QLocalSocket::OperationError); + emit errorOccurred(QLocalSocket::OperationError); return; } @@ -135,7 +135,7 @@ void QLocalSocket::connectToServer(OpenMode openMode) d->error = ServerNotFoundError; d->errorString = tr("%1: Invalid name").arg(QLatin1String("QLocalSocket::connectToServer")); d->state = UnconnectedState; - emit error(d->error); + emit errorOccurred(d->error); emit stateChanged(d->state); return; } -- cgit v1.2.3