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>
This commit is contained in:
Alexander Akulich 2020-02-07 17:29:33 +03:00 committed by Timur Pocheptsov
parent 469c333840
commit cb26a4da69
29 changed files with 103 additions and 89 deletions

View File

@ -89,7 +89,7 @@
The only QTcpSocket signals we need in this example are
QTcpSocket::readyRead(), signifying that data has been received, and
QTcpSocket::error(), which we will use to catch any connection errors:
QTcpSocket::errorOccurred(), which we will use to catch any connection errors:
\dots
\snippet fortuneclient/client.cpp 3
@ -118,11 +118,11 @@
\li \e{An error occurs.} We need to inform the user if the connection
failed or was broken. In this case, QTcpSocket will emit
\l{QTcpSocket::error()}{error()}, and \c Client::displayError() will be
\l{QTcpSocket::errorOccurred()}{errorOccurred()}, and \c Client::displayError() will be
called.
\endlist
Let's go through the \l{QTcpSocket::error()}{error()} case first:
Let's go through the \l{QTcpSocket::errorOccurred()}{errorOccurred()} case first:
\snippet fortuneclient/client.cpp 13

View File

@ -121,7 +121,7 @@ Client::Client(QWidget *parent)
//! [2] //! [3]
connect(tcpSocket, &QIODevice::readyRead, this, &Client::readFortune);
//! [2] //! [4]
connect(tcpSocket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error),
connect(tcpSocket, &QAbstractSocket::errorOccurred,
//! [3]
this, &Client::displayError);
//! [4]

View File

@ -78,7 +78,7 @@ Dialog::Dialog(QWidget *parent)
connect(&tcpClient, &QAbstractSocket::connected, this, &Dialog::startTransfer);
connect(&tcpClient, &QIODevice::bytesWritten,
this, &Dialog::updateClientProgress);
connect(&tcpClient, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error),
connect(&tcpClient, &QAbstractSocket::errorOccurred,
this, &Dialog::displayError);
QVBoxLayout *mainLayout = new QVBoxLayout;
@ -131,8 +131,7 @@ void Dialog::acceptConnection()
connect(tcpServerConnection, &QIODevice::readyRead,
this, &Dialog::updateServerProgress);
connect(tcpServerConnection,
QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error),
connect(tcpServerConnection, &QAbstractSocket::errorOccurred,
this, &Dialog::displayError);
connect(tcpServerConnection, &QTcpSocket::disconnected,
tcpServerConnection, &QTcpSocket::deleteLater);

View File

@ -102,8 +102,7 @@ void Client::newConnection(Connection *connection)
{
connection->setGreetingMessage(peerManager->userName());
connect(connection, QOverload<QAbstractSocket::SocketError>::of(&Connection::error),
this, &Client::connectionError);
connect(connection, &Connection::errorOccurred, this, &Client::connectionError);
connect(connection, &Connection::disconnected, this, &Client::disconnected);
connect(connection, &Connection::readyForUse, this, &Client::readyForUse);
}

View File

@ -107,8 +107,8 @@ PeerWireClient::PeerWireClient(const QByteArray &peerId, QObject *parent)
this, &PeerWireClient::readyRead);
connect(&socket, &QTcpSocket::disconnected,
this, &PeerWireClient::disconnected);
connect(&socket, QOverload<QAbstractSocket::SocketError>::of(&QTcpSocket::error),
this, QOverload<QAbstractSocket::SocketError>::of(&PeerWireClient::error));
connect(&socket, &QTcpSocket::errorOccurred,
this, &PeerWireClient::errorOccurred);
connect(&socket, &QTcpSocket::bytesWritten,
this, &PeerWireClient::bytesWritten);
connect(&socket, &QTcpSocket::stateChanged,

View File

@ -843,7 +843,7 @@ void TorrentClient::initializeConnection(PeerWireClient *client)
this, &TorrentClient::setupOutgoingConnection);
connect(client, &PeerWireClient::disconnected,
this, &TorrentClient::removeClient);
connect(client, QOverload<QAbstractSocket::SocketError>::of(&PeerWireClient::error),
connect(client, &PeerWireClient::errorOccurred,
this, &TorrentClient::removeClient);
connect(client, &PeerWireClient::piecesAvailable,
this, &TorrentClient::peerPiecesAvailable);

View File

@ -80,7 +80,7 @@ void TorrentServer::incomingConnection(qintptr socketDescriptor)
if (ConnectionManager::instance()->canAddConnection() && !clients.isEmpty()) {
connect(client, &PeerWireClient::infoHashReceived,
this, &TorrentServer::processInfoHash);
connect(client, QOverload<QAbstractSocket::SocketError>::of(&PeerWireClient::error),
connect(client, &PeerWireClient::errorOccurred,
this, QOverload<>::of(&TorrentServer::removeClient));
RateController::instance()->addSocket(client);
ConnectionManager::instance()->addConnection(client);

View File

@ -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)),

View File

@ -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);

View File

@ -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

View File

@ -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.,

View File

@ -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

View File

@ -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)),

View File

@ -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

View File

@ -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();

View File

@ -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");

View File

@ -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");

View File

@ -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();

View File

@ -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

View File

@ -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()),

View File

@ -1081,7 +1081,7 @@ private slots:
void acceptNewConnection()
{
serverSocket = server.nextPendingConnection();
connect(serverSocket, SIGNAL(error(QAbstractSocket::SocketError)),
connect(serverSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)),
this, SLOT(remoteHostClosed()));
}

View File

@ -674,7 +674,7 @@ private:
//qDebug() << "connectSocketSignals" << client;
connect(client.data(), SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
connect(client.data(), SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot()));
connect(client.data(), SIGNAL(error(QAbstractSocket::SocketError)),
connect(client.data(), SIGNAL(errorOccurred(QAbstractSocket::SocketError)),
this, SLOT(slotError(QAbstractSocket::SocketError)));
}

View File

@ -270,7 +270,7 @@ void tst_QHttpSocketEngine::errorTest()
socket.setProxy(QNetworkProxy(QNetworkProxy::HttpProxy, hostname, port, username, username));
socket.connectToHost("0.1.2.3", 12345);
connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)),
connect(&socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)),
&QTestEventLoop::instance(), SLOT(exitLoop()));
QTestEventLoop::instance().enterLoop(30);
QVERIFY(!QTestEventLoop::instance().timeout());

View File

@ -283,7 +283,7 @@ void tst_QSocks5SocketEngine::errorTest()
socket.setProxy(QNetworkProxy(QNetworkProxy::Socks5Proxy, hostname, port, username, username));
socket.connectToHost("0.1.2.3", 12345);
connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)),
connect(&socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)),
&QTestEventLoop::instance(), SLOT(exitLoop()));
QTestEventLoop::instance().enterLoop(10);
QVERIFY(!QTestEventLoop::instance().timeout());
@ -753,7 +753,7 @@ void tst_QSocks5SocketEngine::downloadBigFile()
QTestEventLoop::instance().exitLoop();
});
connect(&socket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error),
connect(&socket, &QAbstractSocket::errorOccurred,
[&socket, &stopWatch] (QAbstractSocket::SocketError errorCode)
{
qWarning().noquote().nospace() << QTest::currentTestFunction()
@ -1006,7 +1006,7 @@ void tst_QSocks5SocketEngine::incomplete()
connect(&socket, SIGNAL(connected()),
&QTestEventLoop::instance(), SLOT(exitLoop()));
connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)),
connect(&socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)),
&QTestEventLoop::instance(), SLOT(exitLoop()));
QTestEventLoop::instance().enterLoop(70);
QVERIFY(!QTestEventLoop::instance().timeout());

View File

@ -2019,14 +2019,14 @@ void tst_QTcpSocket::remoteCloseError()
QCOMPARE(clientSocket->bytesAvailable(), qint64(5));
qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError");
QSignalSpy errorSpy(clientSocket, SIGNAL(error(QAbstractSocket::SocketError)));
QSignalSpy errorSpy(clientSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)));
QSignalSpy disconnectedSpy(clientSocket, SIGNAL(disconnected()));
clientSocket->write("World");
serverSocket->disconnectFromHost();
tmpSocket = clientSocket;
connect(clientSocket, SIGNAL(error(QAbstractSocket::SocketError)),
connect(clientSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)),
this, SLOT(remoteCloseErrorSlot()));
enterLoop(30);
@ -2079,7 +2079,7 @@ void tst_QTcpSocket::nestedEventLoopInErrorSlot()
{
QTcpSocket *socket = newSocket();
QPointer<QTcpSocket> p(socket);
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(enterLoopSlot()));
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SLOT(enterLoopSlot()));
socket->connectToHost("hostnotfoundhostnotfound.qt-project.org", 9999);
enterLoop(30);
@ -2109,7 +2109,7 @@ void tst_QTcpSocket::connectToHostError()
QFETCH(int, port);
QFETCH(QAbstractSocket::SocketError, expectedError);
connect(socket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error),[&](QAbstractSocket::SocketError socketError){
connect(socket, &QAbstractSocket::errorOccurred, [&](QAbstractSocket::SocketError socketError){
error = socketError;
});
socket->connectToHost(host, port); // no service running here, one suspects
@ -2326,7 +2326,7 @@ void tst_QTcpSocket::abortiveClose()
qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError");
QSignalSpy readyReadSpy(clientSocket, SIGNAL(readyRead()));
QSignalSpy errorSpy(clientSocket, SIGNAL(error(QAbstractSocket::SocketError)));
QSignalSpy errorSpy(clientSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)));
connect(clientSocket, SIGNAL(disconnected()), this, SLOT(exitLoopSlot()));
QTimer::singleShot(0, this, SLOT(abortiveClose_abortSlot()));
@ -2439,14 +2439,14 @@ void tst_QTcpSocket::connectionRefused()
QTcpSocket *socket = newSocket();
QSignalSpy stateSpy(socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)));
QSignalSpy errorSpy(socket, SIGNAL(error(QAbstractSocket::SocketError)));
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
QSignalSpy errorSpy(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)));
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)),
&QTestEventLoop::instance(), SLOT(exitLoop()));
socket->connectToHost(QtNetworkSettings::httpServerName(), 144);
enterLoop(10);
disconnect(socket, SIGNAL(error(QAbstractSocket::SocketError)),
disconnect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)),
&QTestEventLoop::instance(), SLOT(exitLoop()));
QVERIFY2(!timeout(), "Network timeout");
@ -2773,7 +2773,7 @@ void tst_QTcpSocket::taskQtBug5799ConnectionErrorEventLoop()
// check that we get a proper error connecting to port 12346
// This testcase uses an event loop
QTcpSocket socket;
connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop()));
connect(&socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop()));
socket.connectToHost(QtNetworkSettings::httpServerName(), 12346);
QTestEventLoop::instance().enterLoop(10);
@ -3209,7 +3209,7 @@ void tst_QTcpSocket::readNotificationsAfterBind()
QAbstractSocket socket(QAbstractSocket::TcpSocket, nullptr);
QVERIFY2(socket.bind(), "Bind error!");
connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop()));
connect(&socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop()));
QSignalSpy spyReadyRead(&socket, SIGNAL(readyRead()));
socket.connectToHost(QtNetworkSettings::serverName(), 12346);

View File

@ -883,7 +883,7 @@ void tst_QUdpSocket::writeDatagram()
qRegisterMetaType<QAbstractSocket::SocketError>("QAbstractSocket::SocketError");
for(int i=0;;i++) {
QSignalSpy errorspy(&client, SIGNAL(error(QAbstractSocket::SocketError)));
QSignalSpy errorspy(&client, SIGNAL(errorOccurred(QAbstractSocket::SocketError)));
QSignalSpy bytesspy(&client, SIGNAL(bytesWritten(qint64)));
qint64 written = client.writeDatagram(QByteArray(i * 1024, 'w'), serverAddress,
@ -1044,7 +1044,7 @@ void tst_QUdpSocket::writeToNonExistingPeer()
QUdpSocket sConnected;
QSignalSpy sConnectedReadyReadSpy(&sConnected, SIGNAL(readyRead()));
QSignalSpy sConnectedErrorSpy(&sConnected, SIGNAL(error(QAbstractSocket::SocketError)));
QSignalSpy sConnectedErrorSpy(&sConnected, SIGNAL(errorOccurred(QAbstractSocket::SocketError)));
sConnected.connectToHost(peerAddress, peerPort, QIODevice::ReadWrite);
QVERIFY(sConnected.waitForConnected(10000));

View File

@ -410,7 +410,7 @@ private:
static QString certDirPath;
void (QSslSocket::*socketErrorSignal)(QAbstractSocket::SocketError) = &QAbstractSocket::error;
void (QSslSocket::*socketErrorSignal)(QAbstractSocket::SocketError) = &QAbstractSocket::errorOccurred;
void (QSslSocket::*tlsErrorsSignal)(const QList<QSslError> &) = &QSslSocket::sslErrors;
void (QTestEventLoop::*exitLoopSlot)() = &QTestEventLoop::exitLoop;

View File

@ -1240,7 +1240,7 @@ protected:
configuration.setProtocol(protocol);
if (ignoreSslErrors)
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SIGNAL(socketError(QAbstractSocket::SocketError)));
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SIGNAL(socketError(QAbstractSocket::SocketError)));
QFile file(m_keyFile);
QVERIFY(file.open(QIODevice::ReadOnly));
@ -1377,8 +1377,8 @@ void tst_QSslSocket::protocolServerSide()
socket = &client;
QFETCH(QSsl::SslProtocol, clientProtocol);
socket->setProtocol(clientProtocol);
// upon SSL wrong version error, error will be triggered, not sslErrors
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
// upon SSL wrong version error, errorOccurred will be triggered, not sslErrors
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit()));
@ -1438,8 +1438,8 @@ void tst_QSslSocket::serverCipherPreferences()
sslConfig.setCiphers({QSslCipher("AES256-SHA"), QSslCipher("AES128-SHA")});
socket->setSslConfiguration(sslConfig);
// upon SSL wrong version error, error will be triggered, not sslErrors
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
// upon SSL wrong version error, errorOccurred will be triggered, not sslErrors
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit()));
@ -1470,8 +1470,8 @@ void tst_QSslSocket::serverCipherPreferences()
sslConfig.setCiphers({QSslCipher("AES256-SHA"), QSslCipher("AES128-SHA")});
socket->setSslConfiguration(sslConfig);
// upon SSL wrong version error, error will be triggered, not sslErrors
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
// upon SSL wrong version error, errorOccurred will be triggered, not sslErrors
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit()));
@ -1561,7 +1561,7 @@ void tst_QSslSocket::setLocalCertificateChain()
const QScopedPointer<QSslSocket, QScopedPointerDeleteLater> client(new QSslSocket);
socket = client.data();
connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit()));
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
socket->connectToHostEncrypted(QHostAddress(QHostAddress::LocalHost).toString(), server.serverPort());
@ -2551,8 +2551,8 @@ void tst_QSslSocket::closeWhileEmittingSocketError()
clientConfig.setPeerVerifyMode(QSslSocket::VerifyNone);
clientSocket.setSslConfiguration(clientConfig);
QSignalSpy socketErrorSpy(&clientSocket, SIGNAL(error(QAbstractSocket::SocketError)));
void (QSslSocket::*errorSignal)(QAbstractSocket::SocketError) = &QSslSocket::error;
QSignalSpy socketErrorSpy(&clientSocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)));
void (QSslSocket::*errorSignal)(QAbstractSocket::SocketError) = &QSslSocket::errorOccurred;
connect(&clientSocket, errorSignal, &handshake, &BrokenPskHandshake::socketError);
clientSocket.connectToHostEncrypted(QStringLiteral("127.0.0.1"), handshake.serverPort());
@ -2652,7 +2652,7 @@ void tst_QSslSocket::ignoreSslErrorsList()
socket.ignoreSslErrors(expectedSslErrors);
QFETCH(int, expectedSslErrorSignalCount);
QSignalSpy sslErrorsSpy(&socket, SIGNAL(error(QAbstractSocket::SocketError)));
QSignalSpy sslErrorsSpy(&socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)));
socket.connectToHostEncrypted(QtNetworkSettings::httpServerName(), 443);
@ -2946,13 +2946,13 @@ void tst_QSslSocket::resume()
QSignalSpy sslErrorSpy(&socket, SIGNAL(sslErrors(QList<QSslError>)));
QSignalSpy encryptedSpy(&socket, SIGNAL(encrypted()));
QSignalSpy errorSpy(&socket, SIGNAL(error(QAbstractSocket::SocketError)));
QSignalSpy errorSpy(&socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)));
connect(&socket, SIGNAL(sslErrors(QList<QSslError>)), &QTestEventLoop::instance(), SLOT(exitLoop()));
connect(&socket, SIGNAL(encrypted()), &QTestEventLoop::instance(), SLOT(exitLoop()));
connect(&socket, SIGNAL(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)),
this, SLOT(proxyAuthenticationRequired(QNetworkProxy,QAuthenticator*)));
connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop()));
connect(&socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), &QTestEventLoop::instance(), SLOT(exitLoop()));
socket.connectToHostEncrypted(QtNetworkSettings::imapServerName(), 993);
QTestEventLoop::instance().enterLoop(10);
@ -3263,7 +3263,7 @@ void tst_QSslSocket::dhServer()
QSslSocket client;
socket = &client;
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit()));
@ -3297,7 +3297,7 @@ void tst_QSslSocket::dhServerCustomParamsNull()
QSslSocket client;
socket = &client;
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit()));
@ -3342,7 +3342,7 @@ void tst_QSslSocket::dhServerCustomParams()
QSslSocket client;
socket = &client;
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit()));
@ -3377,7 +3377,7 @@ void tst_QSslSocket::ecdhServer()
QSslSocket client;
socket = &client;
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit()));
@ -3569,7 +3569,7 @@ void tst_QSslSocket::readBufferMaxSize()
QSslSocketPtr client(new QSslSocket);
socket = client.data();
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
connect(socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), &loop, SLOT(quit()));
connect(socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(ignoreErrorSlot()));
connect(socket, SIGNAL(encrypted()), &loop, SLOT(quit()));
@ -3830,7 +3830,7 @@ void tst_QSslSocket::simplePskConnect()
QSignalSpy sslErrorsSpy(&socket, SIGNAL(sslErrors(QList<QSslError>)));
QVERIFY(sslErrorsSpy.isValid());
QSignalSpy socketErrorsSpy(&socket, SIGNAL(error(QAbstractSocket::SocketError)));
QSignalSpy socketErrorsSpy(&socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)));
QVERIFY(socketErrorsSpy.isValid());
QSignalSpy peerVerifyErrorSpy(&socket, SIGNAL(peerVerifyError(QSslError)));
@ -3844,7 +3844,7 @@ void tst_QSslSocket::simplePskConnect()
connect(&socket, SIGNAL(modeChanged(QSslSocket::SslMode)), this, SLOT(exitLoop()));
connect(&socket, SIGNAL(encrypted()), this, SLOT(exitLoop()));
connect(&socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(exitLoop()));
connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(exitLoop()));
connect(&socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SLOT(exitLoop()));
connect(&socket, SIGNAL(peerVerifyError(QSslError)), this, SLOT(exitLoop()));
connect(&socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(exitLoop()));
@ -4112,7 +4112,7 @@ void tst_QSslSocket::pskServer()
connect(&socket, SIGNAL(modeChanged(QSslSocket::SslMode)), this, SLOT(exitLoop()));
connect(&socket, SIGNAL(encrypted()), this, SLOT(exitLoop()));
connect(&socket, SIGNAL(sslErrors(QList<QSslError>)), this, SLOT(exitLoop()));
connect(&socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(exitLoop()));
connect(&socket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)), this, SLOT(exitLoop()));
connect(&socket, SIGNAL(peerVerifyError(QSslError)), this, SLOT(exitLoop()));
connect(&socket, SIGNAL(stateChanged(QAbstractSocket::SocketState)), this, SLOT(exitLoop()));
@ -4292,7 +4292,7 @@ void tst_QSslSocket::signatureAlgorithm()
QEventLoop loop;
QTimer::singleShot(5000, &loop, &QEventLoop::quit);
connect(socket, QOverload<QAbstractSocket::SocketError>::of(&QAbstractSocket::error), &loop, &QEventLoop::quit);
connect(socket, &QAbstractSocket::errorOccurred, &loop, &QEventLoop::quit);
connect(socket, QOverload<const QList<QSslError> &>::of(&QSslSocket::sslErrors), this, &tst_QSslSocket::ignoreErrorSlot);
connect(socket, &QSslSocket::encrypted, &loop, &QEventLoop::quit);

View File

@ -53,7 +53,7 @@ DataTransfererQTcp::DataTransfererQTcp(QObject* parent)
connect(&m_qsocket, SIGNAL(readyRead()), this, SLOT(readyRead()));
connect(&m_qsocket, SIGNAL(connected()), this, SLOT(connected()));
connect(&m_qsocket, SIGNAL(error(QAbstractSocket::SocketError)),
connect(&m_qsocket, SIGNAL(errorOccurred(QAbstractSocket::SocketError)),
this, SLOT(error(QAbstractSocket::SocketError)));
}