summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Trufanov <[email protected]>2017-11-14 14:24:45 +0300
committerAlbert Astals Cid <[email protected]>2017-11-14 22:27:00 +0100
commite91bf07bcfb5f25f791a29a9917b0290b8253447 (patch)
tree0a18f2ed3e2a77228fb3fe3a43fa2809cebaf7b1
parent41d378aef922747fb97e05f6f3353a6ceed9706b (diff)
Try to display a malformed image if feasible
Differential Revision: https://phabricator.kde.org/D8415
-rw-r--r--generators/kimgio/generator_kimgio.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/generators/kimgio/generator_kimgio.cpp b/generators/kimgio/generator_kimgio.cpp
index 2247a2c..2b7db6c 100644
--- a/generators/kimgio/generator_kimgio.cpp
+++ b/generators/kimgio/generator_kimgio.cpp
@@ -69,8 +69,12 @@ bool KIMGIOGenerator::loadDocumentInternal(const QByteArray & fileData, const QS
QImageReader reader( &buffer, QImageReader::imageFormat( &buffer ) );
reader.setAutoDetectImageFormat( true );
if ( !reader.read( &m_img ) ) {
- emit error( i18n( "Unable to load document: %1", reader.errorString() ), -1 );
- return false;
+ if (!m_img.isNull()) {
+ emit warning( i18n( "This document appears malformed. Here is a best approximation of the document's intended appearance." ), -1 );
+ } else {
+ emit error( i18n( "Unable to load document: %1", reader.errorString() ), -1 );
+ return false;
+ }
}
QMimeDatabase db;
auto mime = db.mimeTypeForFileNameAndData( fileName, fileData );