summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2015-03-17 12:09:03 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2015-03-17 09:23:55 -0700
commit002cfa0663b7eeabca65b756515aef4f044c54c6 (patch)
tree970b8eb0856bcf3ab53f35f195f9521af728bba1 /qt-ui
parente0490f305560bef53327ccaab391eb25cf03e260 (diff)
downloadsubsurface-002cfa0663b7eeabca65b756515aef4f044c54c6.tar.gz
Create picture cache directory if needed
Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/divepicturewidget.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/qt-ui/divepicturewidget.cpp b/qt-ui/divepicturewidget.cpp
index 0bf3424bc..ce997fea1 100644
--- a/qt-ui/divepicturewidget.cpp
+++ b/qt-ui/divepicturewidget.cpp
@@ -65,7 +65,11 @@ void ImageDownloader::saveImage(QNetworkReply *reply)
QByteArray imageData = reply->readAll();
QCryptographicHash hash(QCryptographicHash::Sha1);
hash.addData(imageData);
- QFile imageFile(QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first().append("/").append(hash.result().toHex()));
+ QString path = QStandardPaths::standardLocations(QStandardPaths::CacheLocation).first();
+ QDir dir(path);
+ if (!dir.exists())
+ dir.mkpath(path);
+ QFile imageFile(path.append("/").append(hash.result().toHex()));
if (imageFile.open(QIODevice::WriteOnly)) {
QDataStream stream(&imageFile);
stream.writeRawData(imageData.data(), imageData.length());