From 7aa361b424e19144ec15a4a6b23af9265d439ef5 Mon Sep 17 00:00:00 2001 From: Yakup Cengiz Date: Fri, 20 Dec 2019 12:45:49 +0900 Subject: [PATCH] QFtp: Suppress warning about reading from closed QIODevice. Clear bytesFromSocket when the socket is not open instead of reading in QFtpDTP::socketConnectionClosed(), which is connected to QTcpSocket::disconnected(). --- src/qftp/qftp.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/qftp/qftp.cpp b/src/qftp/qftp.cpp index 017a2e4..79a5d2a 100644 --- a/src/qftp/qftp.cpp +++ b/src/qftp/qftp.cpp @@ -744,7 +744,16 @@ void QFtpDTP::socketConnectionClosed() clearData(); } - bytesFromSocket = socket->readAll(); + // check if socket is open before reading data + if (socket->isOpen()) + { + bytesFromSocket = socket->readAll(); + } + else + { + bytesFromSocket.clear(); + } + #if defined(QFTPDTP_DEBUG) qDebug("QFtpDTP::connectState(CsClosed)"); #endif