From 95fd0f881cb4af02569b9a29c6157a8e97bdb74b Mon Sep 17 00:00:00 2001 From: Gary Wang Date: Sun, 1 Nov 2020 13:01:36 +0800 Subject: [PATCH] fix: should tell user if image read failed --- graphicsview.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/graphicsview.cpp b/graphicsview.cpp index af7bcab..b3d3d97 100644 --- a/graphicsview.cpp +++ b/graphicsview.cpp @@ -51,8 +51,15 @@ void GraphicsView::showFileFromUrl(const QUrl &url, bool doRequestGallery) // QImage::Format imageFormat = imageReader.imageFormat(); if (imageReader.format().isEmpty()) { showText(tr("File is not a valid image")); + } else if (!imageReader.supportsAnimation() && !imageReader.canRead()) { + showText(tr("Image data is invalid or currently unsupported")); } else { - showImage(QPixmap::fromImageReader(&imageReader)); + const QPixmap & pixmap = QPixmap::fromImageReader(&imageReader); + if (pixmap.isNull()) { + showText(tr("Image data is invalid or currently unsupported")); + } else { + showImage(pixmap); + } } }