Commit 4b2ba6a7 authored by Alexander Trufanov's avatar Alexander Trufanov

Try to display a malformed image if feasible

Differential Revision: https://phabricator.kde.org/D8415
parent 43cd93a3
...@@ -69,8 +69,12 @@ bool KIMGIOGenerator::loadDocumentInternal(const QByteArray & fileData, const QS ...@@ -69,8 +69,12 @@ bool KIMGIOGenerator::loadDocumentInternal(const QByteArray & fileData, const QS
QImageReader reader( &buffer, QImageReader::imageFormat( &buffer ) ); QImageReader reader( &buffer, QImageReader::imageFormat( &buffer ) );
reader.setAutoDetectImageFormat( true ); reader.setAutoDetectImageFormat( true );
if ( !reader.read( &m_img ) ) { if ( !reader.read( &m_img ) ) {
emit error( i18n( "Unable to load document: %1", reader.errorString() ), -1 ); if (!m_img.isNull()) {
return false; 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; QMimeDatabase db;
auto mime = db.mimeTypeForFileNameAndData( fileName, fileData ); auto mime = db.mimeTypeForFileNameAndData( fileName, fileData );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment