Network-chat example: Only disconnect if still connected
If we are already disconnected we end up printing warnings about how it's illegal to call waitForBytesWritten on an unconnected socket Change-Id: I8c864d105d5372edfee84affb362cca3021b8ea0 Reviewed-by: Konrad Kujawa <konrad.kujawa@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
5a6f51a322
commit
0471df7987
@ -48,7 +48,7 @@ Connection::Connection(qintptr socketDescriptor, QObject *parent)
|
|||||||
|
|
||||||
Connection::~Connection()
|
Connection::~Connection()
|
||||||
{
|
{
|
||||||
if (isGreetingMessageSent) {
|
if (isGreetingMessageSent && QAbstractSocket::state() != QAbstractSocket::UnconnectedState) {
|
||||||
// Indicate clean shutdown.
|
// Indicate clean shutdown.
|
||||||
writer.endArray();
|
writer.endArray();
|
||||||
waitForBytesWritten(2000);
|
waitForBytesWritten(2000);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user