From e0490f305560bef53327ccaab391eb25cf03e260 Mon Sep 17 00:00:00 2001 From: "Robert C. Helling" Date: Tue, 3 Mar 2015 11:12:07 +0100 Subject: [PATCH] Use QUrl::fromUserInput for image files ... as suggested by Thiago. Signed-off-by: Robert C. Helling Signed-off-by: Dirk Hohndel --- qt-ui/divepicturewidget.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/qt-ui/divepicturewidget.cpp b/qt-ui/divepicturewidget.cpp index 6de317778..0bf3424bc 100644 --- a/qt-ui/divepicturewidget.cpp +++ b/qt-ui/divepicturewidget.cpp @@ -20,8 +20,11 @@ void loadPicuture(struct picture *picture) download.load(); } -SHashedImage::SHashedImage(struct picture *picture) : QImage(picture->filename) +SHashedImage::SHashedImage(struct picture *picture) : QImage() { + QUrl url = QUrl::fromUserInput(QString(picture->filename)); + if(url.isLocalFile()) + load(url.toLocalFile()); if (isNull()) { // Hash lookup. load(fileFromHash(picture->hash)); @@ -31,7 +34,7 @@ SHashedImage::SHashedImage(struct picture *picture) : QImage(picture->filename) QtConcurrent::run(loadPicuture, picture); } } else { - QByteArray hash = hashFile(QString(picture->filename)); + QByteArray hash = hashFile(url.toLocalFile()); free(picture->hash); picture->hash = strdup(hash.toHex().data()); } @@ -43,7 +46,7 @@ ImageDownloader::ImageDownloader(struct picture *pic) } void ImageDownloader::load(){ - QUrl url(picture->filename); + QUrl url = QUrl::fromUserInput(QString(picture->filename)); if (url.isValid()) { QEventLoop loop; QNetworkRequest request(url);