Skip to content

Commit

Permalink
fix: dci cannot read when setDecideFormatFromContent
Browse files Browse the repository at this point in the history
QImageReader::setDecideFormatFromContent(bool ignored)
If ignored is set to true, QDciPlugin::create will get
empty format.
  • Loading branch information
kegechen committed Oct 27, 2023
1 parent b80e65a commit 01cd7a9
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions imageformatplugins/dci/qdciiohandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<QBuffer *>(device);
Expand Down Expand Up @@ -95,7 +96,6 @@ QDciIOHandler::QDciIOHandler()

}


QDciIOHandler::~QDciIOHandler()
{
delete d;
Expand All @@ -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;
Expand Down

0 comments on commit 01cd7a9

Please sign in to comment.