summaryrefslogtreecommitdiffstats
path: root/src/plugins/imageformats/ico/qicohandler.h
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2023-10-11 21:41:53 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2024-02-09 12:17:21 -0700
commit3f515fa7aff7cb24565f0bb61b16bb2bde6faf60 (patch)
tree9ce2da47ebc3afc7e2e63475af2b79120dd3a860 /src/plugins/imageformats/ico/qicohandler.h
parent83f7125ac866ed5a2aaace56ffc866f21f9730b4 (diff)
QtIcoHandler::canRead(): avoid checking more than once
QtIcoHandler::canRead() calls ICOReader::canRead(), which assumes that QIODevice::pos() is at the position where the .ico data starts (i.e. pos() == 0 if this is a separate .ico file). But if an AnimatedImage in Qt Quick opens an .ico file, canRead() gets called multiple times: the first is when QQuickAnimatedImage::frameCount() eventually results in QImageReaderPrivate::initHandler(); then ICOReader::readHeader() is called, which moves the file position. The second time is when QQuickAnimatedImage calls QMovie::isValid(). At that time, QIODevice::pos() == 6: we need to avoid calling ICOReader::canRead() because it's no longer at the start of the data. Without this change, AnimatedImage reports "Error Reading Animated Image File" and doesn't show anything. The fix is to store the known-good state, the same way that QTiffHandler::canRead() returns true if its d->tiff already exists (TIFFClientOpen() succeeded). The test checks that it's ok to call QMovie::frameCount() first and then QMovie::isValid(). Calling frameCount() has the effect of moving QIODevice::pos(). Pick-to: 6.5 6.6 6.7 Task-number: QTBUG-117429 Change-Id: Ie3a5225f2cea9a0d76d685e83ce4d4a10cbe9188 Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/plugins/imageformats/ico/qicohandler.h')
-rw-r--r--src/plugins/imageformats/ico/qicohandler.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/plugins/imageformats/ico/qicohandler.h b/src/plugins/imageformats/ico/qicohandler.h
index 0fe251ab60..61c3eea465 100644
--- a/src/plugins/imageformats/ico/qicohandler.h
+++ b/src/plugins/imageformats/ico/qicohandler.h
@@ -30,7 +30,7 @@ public:
private:
int m_currentIconIndex;
ICOReader *m_pICOReader;
-
+ mutable bool knownCanRead = false;
};
QT_END_NAMESPACE