Make QLocalSocket::open set an error when already connected

When attempting to connect a tcp-based QLocalSocket while it was
already connected, the open() (and connectToServer()) method
failed silently. That behavior was not helpful and inconsistent
with the windows and unix implementations.
So an error is now set and error() is emitted

Change-Id: I544e81f0a303dd6d5b1869287df860878a8a06c6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Corentin Jabot 2013-01-14 19:25:31 +01:00 committed by The Qt Project
parent 53de293433
commit 88918abdde

View File

@ -218,6 +218,8 @@ bool QLocalSocket::open(OpenMode openMode)
{
Q_D(QLocalSocket);
if (state() == ConnectedState || state() == ConnectingState) {
setErrorString(tr("Trying to connect while connection is in progress"));
emit error(QLocalSocket::OperationError);
return false;
}