mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Use QUrl::fromUserInput for image files
... as suggested by Thiago. Signed-off-by: Robert C. Helling <helling@atdotde.de> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
6b3b50cc2f
commit
e0490f3055
1 changed files with 6 additions and 3 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Reference in a new issue