summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qabstractsocket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/socket/qabstractsocket.cpp')
-rw-r--r--src/network/socket/qabstractsocket.cpp63
1 files changed, 28 insertions, 35 deletions
diff --git a/src/network/socket/qabstractsocket.cpp b/src/network/socket/qabstractsocket.cpp
index 5f1ff2fcb8..fb792e428f 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.
@@ -215,7 +223,7 @@
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}
*/
/*!
@@ -329,7 +337,8 @@
is non-blocking).
\value UnknownSocketError An unidentified error occurred.
- \sa QAbstractSocket::socketError()
+ \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.,
@@ -2092,7 +2104,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 socketError() to determine
+ 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
@@ -2864,7 +2876,7 @@ void QAbstractSocket::setReadBufferSize(qint64 size)
/*!
Returns the state of the socket.
- \sa socketError()
+ \sa error()
*/
QAbstractSocket::SocketState QAbstractSocket::state() const
{
@@ -2891,35 +2903,16 @@ 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(), 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
+QAbstractSocket::SocketError QAbstractSocket::error() const
{
return d_func()->socketError;
}
-
/*!
Sets the type of error that last occurred to \a socketError.