QLocalSocket: Rename private errorOccurred method to setErrorAndEmit()
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 <marten.nordheim@qt.io>
This commit is contained in:
parent
c034f92fc2
commit
1c573ba47c
@ -125,7 +125,7 @@ public:
|
|||||||
bool ownsTcpSocket;
|
bool ownsTcpSocket;
|
||||||
void setSocket(QLocalUnixSocket*);
|
void setSocket(QLocalUnixSocket*);
|
||||||
QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const;
|
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_stateChanged(QAbstractSocket::SocketState newState);
|
||||||
void _q_error(QAbstractSocket::SocketError newError);
|
void _q_error(QAbstractSocket::SocketError newError);
|
||||||
#elif defined(Q_OS_WIN)
|
#elif defined(Q_OS_WIN)
|
||||||
@ -142,7 +142,7 @@ public:
|
|||||||
qint64 skip(qint64 maxSize) override;
|
qint64 skip(qint64 maxSize) override;
|
||||||
QLocalUnixSocket unixSocket;
|
QLocalUnixSocket unixSocket;
|
||||||
QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const;
|
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_stateChanged(QAbstractSocket::SocketState newState);
|
||||||
void _q_error(QAbstractSocket::SocketError newError);
|
void _q_error(QAbstractSocket::SocketError newError);
|
||||||
void _q_connectToSocket();
|
void _q_connectToSocket();
|
||||||
|
@ -168,7 +168,7 @@ QString QLocalSocketPrivate::generateErrorString(QLocalSocket::LocalSocketError
|
|||||||
return errorString;
|
return errorString;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QLocalSocketPrivate::errorOccurred(QLocalSocket::LocalSocketError error, const QString &function)
|
void QLocalSocketPrivate::setErrorAndEmit(QLocalSocket::LocalSocketError error, const QString &function)
|
||||||
{
|
{
|
||||||
Q_Q(QLocalSocket);
|
Q_Q(QLocalSocket);
|
||||||
switch (error) {
|
switch (error) {
|
||||||
@ -231,7 +231,7 @@ void QLocalSocket::connectToServer(OpenMode openMode)
|
|||||||
emit stateChanged(d->state);
|
emit stateChanged(d->state);
|
||||||
|
|
||||||
if (d->serverName.isEmpty()) {
|
if (d->serverName.isEmpty()) {
|
||||||
d->errorOccurred(ServerNotFoundError,
|
d->setErrorAndEmit(ServerNotFoundError,
|
||||||
QLatin1String("QLocalSocket::connectToServer"));
|
QLatin1String("QLocalSocket::connectToServer"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -246,7 +246,7 @@ void QLocalSocket::connectToServer(OpenMode openMode)
|
|||||||
bool ok;
|
bool ok;
|
||||||
const quint16 port = settings.value(d->fullServerName).toUInt(&ok);
|
const quint16 port = settings.value(d->fullServerName).toUInt(&ok);
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
d->errorOccurred(ServerNotFoundError,
|
d->setErrorAndEmit(ServerNotFoundError,
|
||||||
QLatin1String("QLocalSocket::connectToServer"));
|
QLatin1String("QLocalSocket::connectToServer"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ QString QLocalSocketPrivate::generateErrorString(QLocalSocket::LocalSocketError
|
|||||||
return errorString;
|
return errorString;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QLocalSocketPrivate::errorOccurred(QLocalSocket::LocalSocketError error, const QString &function)
|
void QLocalSocketPrivate::setErrorAndEmit(QLocalSocket::LocalSocketError error, const QString &function)
|
||||||
{
|
{
|
||||||
Q_Q(QLocalSocket);
|
Q_Q(QLocalSocket);
|
||||||
switch (error) {
|
switch (error) {
|
||||||
@ -237,14 +237,14 @@ void QLocalSocket::connectToServer(OpenMode openMode)
|
|||||||
emit stateChanged(d->state);
|
emit stateChanged(d->state);
|
||||||
|
|
||||||
if (d->serverName.isEmpty()) {
|
if (d->serverName.isEmpty()) {
|
||||||
d->errorOccurred(ServerNotFoundError,
|
d->setErrorAndEmit(ServerNotFoundError,
|
||||||
QLatin1String("QLocalSocket::connectToServer"));
|
QLatin1String("QLocalSocket::connectToServer"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the socket
|
// create the socket
|
||||||
if (-1 == (d->connectingSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, 0, O_NONBLOCK))) {
|
if (-1 == (d->connectingSocket = qt_safe_socket(PF_UNIX, SOCK_STREAM, 0, O_NONBLOCK))) {
|
||||||
d->errorOccurred(UnsupportedSocketOperationError,
|
d->setErrorAndEmit(UnsupportedSocketOperationError,
|
||||||
QLatin1String("QLocalSocket::connectToServer"));
|
QLatin1String("QLocalSocket::connectToServer"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -281,7 +281,7 @@ void QLocalSocketPrivate::_q_connectToSocket()
|
|||||||
name.sun_family = PF_UNIX;
|
name.sun_family = PF_UNIX;
|
||||||
if (sizeof(name.sun_path) < (uint)encodedConnectingPathName.size() + 1) {
|
if (sizeof(name.sun_path) < (uint)encodedConnectingPathName.size() + 1) {
|
||||||
QString function = QLatin1String("QLocalSocket::connectToServer");
|
QString function = QLatin1String("QLocalSocket::connectToServer");
|
||||||
errorOccurred(QLocalSocket::ServerNotFoundError, function);
|
setErrorAndEmit(QLocalSocket::ServerNotFoundError, function);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
::memcpy(name.sun_path, encodedConnectingPathName.constData(),
|
::memcpy(name.sun_path, encodedConnectingPathName.constData(),
|
||||||
@ -292,17 +292,17 @@ void QLocalSocketPrivate::_q_connectToSocket()
|
|||||||
{
|
{
|
||||||
case EINVAL:
|
case EINVAL:
|
||||||
case ECONNREFUSED:
|
case ECONNREFUSED:
|
||||||
errorOccurred(QLocalSocket::ConnectionRefusedError, function);
|
setErrorAndEmit(QLocalSocket::ConnectionRefusedError, function);
|
||||||
break;
|
break;
|
||||||
case ENOENT:
|
case ENOENT:
|
||||||
errorOccurred(QLocalSocket::ServerNotFoundError, function);
|
setErrorAndEmit(QLocalSocket::ServerNotFoundError, function);
|
||||||
break;
|
break;
|
||||||
case EACCES:
|
case EACCES:
|
||||||
case EPERM:
|
case EPERM:
|
||||||
errorOccurred(QLocalSocket::SocketAccessError, function);
|
setErrorAndEmit(QLocalSocket::SocketAccessError, function);
|
||||||
break;
|
break;
|
||||||
case ETIMEDOUT:
|
case ETIMEDOUT:
|
||||||
errorOccurred(QLocalSocket::SocketTimeoutError, function);
|
setErrorAndEmit(QLocalSocket::SocketTimeoutError, function);
|
||||||
break;
|
break;
|
||||||
case EAGAIN:
|
case EAGAIN:
|
||||||
// Try again later, all of the sockets listening are full
|
// Try again later, all of the sockets listening are full
|
||||||
@ -320,7 +320,7 @@ void QLocalSocketPrivate::_q_connectToSocket()
|
|||||||
delayConnect->setEnabled(true);
|
delayConnect->setEnabled(true);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
errorOccurred(QLocalSocket::UnknownSocketError, function);
|
setErrorAndEmit(QLocalSocket::UnknownSocketError, function);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -336,7 +336,7 @@ void QLocalSocketPrivate::_q_connectToSocket()
|
|||||||
q->emit connected();
|
q->emit connected();
|
||||||
} else {
|
} else {
|
||||||
QString function = QLatin1String("QLocalSocket::connectToServer");
|
QString function = QLatin1String("QLocalSocket::connectToServer");
|
||||||
errorOccurred(QLocalSocket::UnknownSocketError, function);
|
setErrorAndEmit(QLocalSocket::UnknownSocketError, function);
|
||||||
}
|
}
|
||||||
connectingSocket = -1;
|
connectingSocket = -1;
|
||||||
connectingName.clear();
|
connectingName.clear();
|
||||||
@ -529,7 +529,7 @@ bool QLocalSocket::waitForConnected(int msec)
|
|||||||
const int result = qt_poll_msecs(&pfd, 1, timeout);
|
const int result = qt_poll_msecs(&pfd, 1, timeout);
|
||||||
|
|
||||||
if (result == -1)
|
if (result == -1)
|
||||||
d->errorOccurred(QLocalSocket::UnknownSocketError,
|
d->setErrorAndEmit(QLocalSocket::UnknownSocketError,
|
||||||
QLatin1String("QLocalSocket::waitForConnected"));
|
QLatin1String("QLocalSocket::waitForConnected"));
|
||||||
else if (result > 0)
|
else if (result > 0)
|
||||||
d->_q_connectToSocket();
|
d->_q_connectToSocket();
|
||||||
|
Loading…
Reference in New Issue
Block a user