summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorBenjamin C Meyer <benjamin.meyer@torchmobile.com>2009-05-06 00:00:12 (GMT)
committerPeter Hartmann <peter.hartmann@trolltech.com>2009-05-06 14:30:11 (GMT)
commitec8fef8f17ac69bacc3d250a0d5932c336276bc5 (patch)
treea51824879e59e50e967374b19229a7d81bbddc9c /src/network
parent91ffeeb342ce85dbd24f49c45adce5cb21a973a4 (diff)
downloadQt-ec8fef8f17ac69bacc3d250a0d5932c336276bc5.zip
Qt-ec8fef8f17ac69bacc3d250a0d5932c336276bc5.tar.gz
Qt-ec8fef8f17ac69bacc3d250a0d5932c336276bc5.tar.bz2
QNetworkDiskCache: check if opening file succeeds
In QNetworkDiskCache::prepare() When QTemporaryFile::open fails, delete the cache item and return 0 rather then returning a closed device. And a spelling mistake in a qWarning() Reviewed-by: Peter Hartmann
Diffstat (limited to 'src/network')
-rw-r--r--src/network/access/qnetworkdiskcache.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp
index 93360c8..892929e 100644
--- a/src/network/access/qnetworkdiskcache.cpp
+++ b/src/network/access/qnetworkdiskcache.cpp
@@ -191,7 +191,11 @@ QIODevice *QNetworkDiskCache::prepare(const QNetworkCacheMetaData &metaData)
} else {
QString templateName = d->tmpCacheFileName();
cacheItem->file = new QTemporaryFile(templateName, &cacheItem->data);
- cacheItem->file->open();
+ if (!cacheItem->file->open()) {
+ qWarning() << "QNetworkDiskCache::prepare() unable to open temporary file";
+ delete cacheItem;
+ return 0;
+ }
cacheItem->writeHeader(cacheItem->file);
device = cacheItem->file;
}
@@ -229,7 +233,7 @@ void QNetworkDiskCachePrivate::storeItem(QCacheItem *cacheItem)
if (QFile::exists(fileName)) {
if (!QFile::remove(fileName)) {
- qWarning() << "QNetworkDiskCache: could't remove the cache file " << fileName;
+ qWarning() << "QNetworkDiskCache: couldn't remove the cache file " << fileName;
return;
}
}