diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-03-25 16:46:16 +0200 |
---|---|---|
committer | Lubomir I. Ivanov <neolit123@gmail.com> | 2018-04-01 15:59:46 +0300 |
commit | 376b73789115833edbcdbed86d5e709cab2ab050 (patch) | |
tree | 11aa75b211df1f124cf69ee8d19a889bf4ebd548 /core/imagedownloader.cpp | |
parent | 028f53c63b1308aa07edb58c6393e26b447d6ee3 (diff) | |
download | subsurface-376b73789115833edbcdbed86d5e709cab2ab050.tar.gz |
Debug: sprinkle debug messages in thumbnailing code
To ease trouble-shooting of the picture thumbnailer add a number
of debug- and info-messages.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'core/imagedownloader.cpp')
-rw-r--r-- | core/imagedownloader.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/core/imagedownloader.cpp b/core/imagedownloader.cpp index fe0bf138a..aaab9a434 100644 --- a/core/imagedownloader.cpp +++ b/core/imagedownloader.cpp @@ -44,6 +44,7 @@ bool ImageDownloader::loadFromUrl(const QUrl &url) connect(&manager, &QNetworkAccessManager::finished, this, [this,&success] (QNetworkReply *reply) { saveImage(reply, success); }); connect(&manager, &QNetworkAccessManager::finished, &loop, &QEventLoop::quit); + qDebug() << "Downloading image from" << url; QNetworkReply *reply = manager.get(request); loop.exec(); delete reply; @@ -68,6 +69,7 @@ void ImageDownloader::saveImage(QNetworkReply *reply, bool &success) dir.mkpath(path); QFile imageFile(path.append("/").append(hash.result().toHex())); if (imageFile.open(QIODevice::WriteOnly)) { + qDebug() << "Write image to" << imageFile.fileName(); QDataStream stream(&imageFile); stream.writeRawData(imageData.data(), imageData.length()); imageFile.waitForBytesWritten(-1); @@ -103,12 +105,18 @@ static void loadPicture(struct picture *picture, bool fromHash) SHashedImage::SHashedImage(struct picture *picture) : QImage() { QUrl url = QUrl::fromUserInput(localFilePath(QString(picture->filename))); - if(url.isLocalFile()) + if (url.isLocalFile()) { load(url.toLocalFile()); + if (isNull()) + qInfo() << "Failed loading picture" << url.toLocalFile(); + else + qDebug() << "Loaded picture" << url.toLocalFile(); + } if (isNull()) { // This did not load anything. Let's try to get the image from other sources // Let's try to load it locally via its hash QString filename = localFilePath(picture->filename); + qDebug() << QStringLiteral("Translated filename: %1 -> %2").arg(picture->filename, filename); if (filename.isNull()) { // That didn't produce a local filename. // Try the cloud server @@ -119,9 +127,11 @@ SHashedImage::SHashedImage(struct picture *picture) : QImage() load(filename); if (!isNull()) { // Make sure the hash still matches the image file + qDebug() << "Loaded picture from translated filename" << filename; QtConcurrent::run(hashPicture, clone_picture(picture)); } else { // Interpret filename as URL + qInfo() << "Failed loading picture from translated filename" << filename; QtConcurrent::run(loadPicture, clone_picture(picture), false); } } |