This applies to both local and abstract sockets.
Task-number: QTBUG-22450
Change-Id: I5c58d68da95ffb6bcde5be510853359b288e5984
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Peter Hartmann <peter.hartmann@nokia.com>
proxy) was not found.
\value ProxyProtocolError The connection negotiation with the proxy server
because the response from the proxy server could not be understood.
+ \value OperationError An operation was attempted while the socket was in a state that
+ did not permit it.
\value UnknownSocketError An unidentified error occurred.
\sa QAbstractSocket::error()
if (d->state == ConnectedState || d->state == ConnectingState
|| d->state == ClosingState || d->state == HostLookupState) {
qWarning("QAbstractSocket::connectToHost() called when already looking up or connecting/connected to \"%s\"", qPrintable(hostName));
+ d->socketError = QAbstractSocket::OperationError;
+ setErrorString(QAbstractSocket::tr("Trying to connect while connection is in progress"));
+ emit error(d->socketError);
return;
}
ProxyConnectionTimeoutError,
ProxyNotFoundError,
ProxyProtocolError,
+ OperationError,
UnknownSocketError = -1
};
\value ConnectionError An error occurred with the connection.
\value UnsupportedSocketOperationError The requested socket operation
is not supported by the local operating system.
+ \value OperationError An operation was attempted while the socket was in a state that
+ did not permit it.
\value UnknownSocketError An unidentified error occurred.
*/
DatagramTooLargeError = QAbstractSocket::DatagramTooLargeError,
ConnectionError = QAbstractSocket::NetworkError,
UnsupportedSocketOperationError = QAbstractSocket::UnsupportedSocketOperationError,
- UnknownSocketError = QAbstractSocket::UnknownSocketError
+ UnknownSocketError = QAbstractSocket::UnknownSocketError,
+ OperationError = QAbstractSocket::OperationError
};
enum LocalSocketState
case QLocalSocket::UnsupportedSocketOperationError:
errorString = QLocalSocket::tr("%1: The socket operation is not supported").arg(function);
break;
+ case QLocalSocket::OperationError:
+ errorString = QLocalSocket::tr("%1: Operation not permitted when socket is in this state").arg(function);
+ break;
case QLocalSocket::UnknownSocketError:
default:
errorString = QLocalSocket::tr("%1: Unknown error").arg(function);
case QLocalSocket::UnsupportedSocketOperationError:
errorString = QLocalSocket::tr("%1: The socket operation is not supported").arg(function);
break;
+ case QLocalSocket::OperationError:
+ errorString = QLocalSocket::tr("%1: Operation not permitted when socket is in this state").arg(function);
+ break;
case QLocalSocket::UnknownSocketError:
default:
errorString = QLocalSocket::tr("%1: Unknown error %2").arg(function).arg(errno);
void QLocalSocket::connectToServer(const QString &name, OpenMode openMode)
{
Q_D(QLocalSocket);
- if (state() == ConnectedState
- || state() == ConnectingState)
+ if (state() == ConnectedState || state() == ConnectingState) {
+ QString errorString = d->generateErrorString(QLocalSocket::OperationError, QLatin1String("QLocalSocket::connectToserver"));
+ setErrorString(errorString);
+ emit error(QLocalSocket::OperationError);
return;
+ }
d->errorString.clear();
d->unixSocket.setSocketState(QAbstractSocket::ConnectingState);
void QLocalSocket::connectToServer(const QString &name, OpenMode openMode)
{
Q_D(QLocalSocket);
- if (state() == ConnectedState || state() == ConnectingState)
+ if (state() == ConnectedState || state() == ConnectingState) {
+ setErrorString("Trying to connect while connection is in progress");
+ emit error(QLocalSocket::OperationError);
return;
+ }
d->error = QLocalSocket::UnknownSocketError;
d->errorString = QString();