diff options
author | Benjamin C Meyer <ben@meyerhome.net> | 2009-09-01 07:51:56 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2009-09-01 08:32:11 (GMT) |
commit | 925912ebf552417306a5bd20fd986afda6a582be (patch) | |
tree | d459905a04f1540fef8569d03417647c95a98ef4 /tests/auto | |
parent | 63e2f5d2c95ece21fd32d0690022b89c38fee865 (diff) | |
download | Qt-925912ebf552417306a5bd20fd986afda6a582be.zip Qt-925912ebf552417306a5bd20fd986afda6a582be.tar.gz Qt-925912ebf552417306a5bd20fd986afda6a582be.tar.bz2 |
QNetworkAccessManager can delete the QAbstractNetworkCache pointer at
any point. Rather then keep a separate pointer to the cache in the
reply use the pointer kept by the manager so the reply never tries
to access a cache pointer that has already been deleted.
Autotest: included
Merge-request: 1124
Reviewed-by: Thiago Macieira <thiago.macieira@nokia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp index e338075..ee49210 100644 --- a/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp +++ b/tests/auto/qabstractnetworkcache/tst_qabstractnetworkcache.cpp @@ -69,6 +69,8 @@ private slots: void cacheControl_data(); void cacheControl(); + void deleteCache(); + private: void check(); }; @@ -269,6 +271,20 @@ void tst_QAbstractNetworkCache::check() QCOMPARE(diskCache->gotData, fetchFromCache); } +void tst_QAbstractNetworkCache::deleteCache() +{ + QNetworkAccessManager manager; + NetworkDiskCache *diskCache = new NetworkDiskCache(&manager); + manager.setCache(diskCache); + + QString url = "httpcachetest_cachecontrol.cgi?max-age=1000"; + QNetworkRequest request(QUrl(TESTFILE + url)); + QNetworkReply *reply = manager.get(request); + QSignalSpy downloaded1(reply, SIGNAL(finished())); + manager.setCache(0); + QTRY_COMPARE(downloaded1.count(), 1); +} + QTEST_MAIN(tst_QAbstractNetworkCache) #include "tst_qabstractnetworkcache.moc" |