From 01cd7a9a84cedb1ca1441b012940f7c05dd67021 Mon Sep 17 00:00:00 2001 From: ck Date: Fri, 27 Oct 2023 09:19:17 +0800 Subject: [PATCH] fix: dci cannot read when setDecideFormatFromContent QImageReader::setDecideFormatFromContent(bool ignored) If ignored is set to true, QDciPlugin::create will get empty format. --- imageformatplugins/dci/qdciiohandler.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/imageformatplugins/dci/qdciiohandler.cpp b/imageformatplugins/dci/qdciiohandler.cpp index f7c17613..c63373ac 100644 --- a/imageformatplugins/dci/qdciiohandler.cpp +++ b/imageformatplugins/dci/qdciiohandler.cpp @@ -48,8 +48,9 @@ bool QDciIOHandlerPrivate::load(QIODevice *device) if (loaded) return current; - if (q->format().isEmpty()) + if (q->format().isEmpty() && !q->canRead()) return false; + loaded = true; QBuffer *buf = qobject_cast(device); @@ -95,7 +96,6 @@ QDciIOHandler::QDciIOHandler() } - QDciIOHandler::~QDciIOHandler() { delete d; @@ -110,6 +110,10 @@ bool QDciIOHandler::canRead() const QByteArray buf = device()->peek(4); if (buf.startsWith(QByteArrayLiteral("DCI"))) { + // Decide format from content.. + if (format().isEmpty()) + setFormat("dci"); + return true; } return false;