fix: should tell user if image read failed

This commit is contained in:
Gary Wang 2020-11-01 13:01:36 +08:00
parent 0a9ea1982b
commit 95fd0f881c

View File

@ -51,8 +51,15 @@ void GraphicsView::showFileFromUrl(const QUrl &url, bool doRequestGallery)
// QImage::Format imageFormat = imageReader.imageFormat(); // QImage::Format imageFormat = imageReader.imageFormat();
if (imageReader.format().isEmpty()) { if (imageReader.format().isEmpty()) {
showText(tr("File is not a valid image")); showText(tr("File is not a valid image"));
} else if (!imageReader.supportsAnimation() && !imageReader.canRead()) {
showText(tr("Image data is invalid or currently unsupported"));
} else { } 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);
}
} }
} }