Try to display a malformed image if feasible

Differential Revision: https://phabricator.kde.org/D8415
This commit is contained in:
Alexander Trufanov 2017-11-14 14:24:45 +03:00 committed by Albert Astals Cid
parent 41d378aef9
commit e91bf07bcf

View file

@ -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 );