From e4343f4f46b9b8fba09af17c127ebbe46d1b32b1 Mon Sep 17 00:00:00 2001 From: James Turner Date: Tue, 30 Jan 2018 18:40:41 +0000 Subject: [PATCH] Launcher: reduce warnings loading thumbnail data --- src/GUI/ThumbnailImageItem.cxx | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/GUI/ThumbnailImageItem.cxx b/src/GUI/ThumbnailImageItem.cxx index cc7d6b944..501cb6c82 100644 --- a/src/GUI/ThumbnailImageItem.cxx +++ b/src/GUI/ThumbnailImageItem.cxx @@ -37,8 +37,10 @@ public: QImage img = QImage::fromData(QByteArray::fromRawData(reinterpret_cast(bytes), length)); if (img.isNull()) { - qWarning() << "failed to load image data for URL:" << - QString::fromStdString(aThumbnailUrl); + if (length > 0) { + // warn if we had valid bytes but couldn't load it, i.e corrupted data or similar + qWarning() << "failed to load image data for URL:" << QString::fromStdString(aThumbnailUrl); + } return; } @@ -130,13 +132,15 @@ void ThumbnailImageItem::setAircraftUri(QString uri) const QString thumbnailPath = aircraftSetPath.dir().filePath("thumbnail.jpg"); m_imageUrl = QUrl::fromLocalFile(thumbnailPath); - QImage img; - if (img.load(thumbnailPath)) { - setImage(img); - } else { - qWarning() << Q_FUNC_INFO << "failed to load thumbnail from:" << thumbnailPath; + if (QFileInfo(thumbnailPath).exists()) { + QImage img; + if (img.load(thumbnailPath)) { + setImage(img); + } else { + qWarning() << Q_FUNC_INFO << "failed to load thumbnail from:" << thumbnailPath; + } } - } + } // of local aircraft case emit aircraftUriChanged(); }