Abort FTP download, not the whole application

An old coding error meant that the C runtime abort() function was
being called instead of QFtp::abort() when cancelling an FTP download
using QNetworkReply::close()

Task-number: QTBUG-22820
Change-Id: Ib97fda9769b2b55a08c042c66c4444cb6216d2b1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Shane Kearns 2012-02-14 20:12:42 +00:00 committed by Qt by Nokia
parent 45bf920947
commit a28c433b29
2 changed files with 25 additions and 5 deletions

View File

@ -179,11 +179,7 @@ void QNetworkAccessFtpBackend::closeDownstreamChannel()
{
state = Disconnecting;
if (operation() == QNetworkAccessManager::GetOperation)
#ifndef Q_OS_WINCE
abort();
#else
exit(3);
#endif
ftp->abort();
}
void QNetworkAccessFtpBackend::downstreamReadyWrite()

View File

@ -392,6 +392,9 @@ private Q_SLOTS:
void synchronousAuthenticationCache();
void pipelining();
void closeDuringDownload_data();
void closeDuringDownload();
// NOTE: This test must be last!
void parentingRepliesToTheApp();
};
@ -6736,6 +6739,27 @@ void tst_QNetworkReply::pipeliningHelperSlot() {
}
}
void tst_QNetworkReply::closeDuringDownload_data()
{
QTest::addColumn<QUrl>("url");
QTest::newRow("http") << QUrl("http://" + QtNetworkSettings::serverName() + "/bigfile");
QTest::newRow("ftp") << QUrl("ftp://" + QtNetworkSettings::serverName() + "/qtest/bigfile");
}
void tst_QNetworkReply::closeDuringDownload()
{
QFETCH(QUrl, url);
QNetworkRequest request(url);
QNetworkReply* reply = manager.get(request);
connect(reply, SIGNAL(readyRead()), &QTestEventLoop::instance(), SLOT(exitLoop()));
QTestEventLoop::instance().enterLoop(10);
QVERIFY(!QTestEventLoop::instance().timeout());
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
reply->close();
reply->deleteLater();
QTest::qWait(1000); //cancelling ftp takes some time, this avoids a warning caused by test's cleanup() destroying the connection cache before the abort is finished
}
// NOTE: This test must be last testcase in tst_qnetworkreply!
void tst_QNetworkReply::parentingRepliesToTheApp()
{