QLocalSocket: Deprecate 'error' signal, use 'errorOccurred' instead
[ChangeLog][Deprecation Notice] QLocalSocket::error() (the signal) is deprecated; superseded by errorOccurred() Change-Id: I579c07564f5c470cf2867864755e0a26e6afce3b Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
1c573ba47c
commit
c08b0cec2f
@ -83,8 +83,7 @@ Client::Client(QWidget *parent)
|
||||
this, &Client::requestNewFortune);
|
||||
connect(quitButton, &QPushButton::clicked, this, &Client::close);
|
||||
connect(socket, &QLocalSocket::readyRead, this, &Client::readFortune);
|
||||
connect(socket, QOverload<QLocalSocket::LocalSocketError>::of(&QLocalSocket::error),
|
||||
this, &Client::displayError);
|
||||
connect(socket, &QLocalSocket::errorOccurred, this, &Client::displayError);
|
||||
|
||||
QGridLayout *mainLayout = new QGridLayout(this);
|
||||
mainLayout->addWidget(hostLabel, 0, 0);
|
||||
|
@ -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<QLocalSocket::LocalSocketError>::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()
|
||||
*/
|
||||
|
@ -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:
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ public:
|
||||
this, SLOT(slotConnected()));
|
||||
connect(this, SIGNAL(disconnected()),
|
||||
this, SLOT(slotDisconnected()));
|
||||
connect(this, SIGNAL(error(QLocalSocket::LocalSocketError)),
|
||||
connect(this, SIGNAL(errorOccurred(QLocalSocket::LocalSocketError)),
|
||||
this, SLOT(slotError(QLocalSocket::LocalSocketError)));
|
||||
connect(this, SIGNAL(stateChanged(QLocalSocket::LocalSocketState)),
|
||||
this, SLOT(slotStateChanged(QLocalSocket::LocalSocketState)));
|
||||
@ -192,7 +192,7 @@ private slots:
|
||||
{
|
||||
QCOMPARE(state(), QLocalSocket::UnconnectedState);
|
||||
}
|
||||
void slotError(QLocalSocket::LocalSocketError newError)
|
||||
void slotErrorOccurred(QLocalSocket::LocalSocketError newError)
|
||||
{
|
||||
QVERIFY(errorString() != QLatin1String("Unknown error"));
|
||||
QCOMPARE(error(), newError);
|
||||
@ -244,7 +244,7 @@ void tst_QLocalSocket::socket_basic()
|
||||
LocalSocket socket;
|
||||
QSignalSpy spyConnected(&socket, SIGNAL(connected()));
|
||||
QSignalSpy spyDisconnected(&socket, SIGNAL(disconnected()));
|
||||
QSignalSpy spyError(&socket, SIGNAL(error(QLocalSocket::LocalSocketError)));
|
||||
QSignalSpy spyError(&socket, SIGNAL(errorOccurred(QLocalSocket::LocalSocketError)));
|
||||
QSignalSpy spyStateChanged(&socket, SIGNAL(stateChanged(QLocalSocket::LocalSocketState)));
|
||||
QSignalSpy spyReadyRead(&socket, SIGNAL(readyRead()));
|
||||
|
||||
@ -359,7 +359,7 @@ void tst_QLocalSocket::listenAndConnect()
|
||||
|
||||
QSignalSpy spyConnected(socket, SIGNAL(connected()));
|
||||
QSignalSpy spyDisconnected(socket, SIGNAL(disconnected()));
|
||||
QSignalSpy spyError(socket, SIGNAL(error(QLocalSocket::LocalSocketError)));
|
||||
QSignalSpy spyError(socket, SIGNAL(errorOccurred(QLocalSocket::LocalSocketError)));
|
||||
QSignalSpy spyStateChanged(socket, SIGNAL(stateChanged(QLocalSocket::LocalSocketState)));
|
||||
QSignalSpy spyReadyRead(socket, SIGNAL(readyRead()));
|
||||
|
||||
@ -525,7 +525,7 @@ void tst_QLocalSocket::sendData()
|
||||
LocalSocket socket;
|
||||
QSignalSpy spyConnected(&socket, SIGNAL(connected()));
|
||||
QSignalSpy spyDisconnected(&socket, SIGNAL(disconnected()));
|
||||
QSignalSpy spyError(&socket, SIGNAL(error(QLocalSocket::LocalSocketError)));
|
||||
QSignalSpy spyError(&socket, SIGNAL(errorOccurred(QLocalSocket::LocalSocketError)));
|
||||
QSignalSpy spyStateChanged(&socket, SIGNAL(stateChanged(QLocalSocket::LocalSocketState)));
|
||||
QSignalSpy spyReadyRead(&socket, SIGNAL(readyRead()));
|
||||
|
||||
@ -1104,7 +1104,7 @@ void tst_QLocalSocket::recycleClientSocket()
|
||||
QVERIFY(server.listen(serverName));
|
||||
QLocalSocket client;
|
||||
QSignalSpy clientReadyReadSpy(&client, SIGNAL(readyRead()));
|
||||
QSignalSpy clientErrorSpy(&client, SIGNAL(error(QLocalSocket::LocalSocketError)));
|
||||
QSignalSpy clientErrorSpy(&client, SIGNAL(errorOccurred(QLocalSocket::LocalSocketError)));
|
||||
for (int i = 0; i < lines.count(); ++i) {
|
||||
client.abort();
|
||||
clientReadyReadSpy.clear();
|
||||
|
Loading…
Reference in New Issue
Block a user