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,9 +69,13 @@ bool KIMGIOGenerator::loadDocumentInternal(const QByteArray & fileData, const QS
QImageReader reader( &buffer, QImageReader::imageFormat( &buffer ) );
reader.setAutoDetectImageFormat( true );
if ( !reader.read( &m_img ) ) {
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 );
docInfo.set( Okular::DocumentInfo::MimeType, mime.name() );
......
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