diff options
author | Alexander Anokhin <alexander@anokhin.me> | 2012-03-15 08:05:31 (GMT) |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-03-19 23:42:58 (GMT) |
commit | bfbfbb8ae1a52de8ebe4d718fe1dd2e2234b8c89 (patch) | |
tree | 7265302f0e033c62e09b078f767c8f72533c2a0b /src | |
parent | 68b1d5c17aa38d5921bdade2b0e0cb67c6c90513 (diff) | |
download | Qt-bfbfbb8ae1a52de8ebe4d718fe1dd2e2234b8c89.zip Qt-bfbfbb8ae1a52de8ebe4d718fe1dd2e2234b8c89.tar.gz Qt-bfbfbb8ae1a52de8ebe4d718fe1dd2e2234b8c89.tar.bz2 |
TGA imageformat: fix broken canRead plugin function
Plugin is now moving QIODevice pos to 0 before
exiting from canRead function, so it doesn't break
other existing imageformat plugins functionality.
Task-number: QTBUG-24201
Change-Id: Ib58b0458215cf5ad705dffa0aaf6a7463d1f089e
Reviewed-by: Sarah Jane Smith <sarah.j.smith@nokia.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/imageformats/tga/qtgafile.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/plugins/imageformats/tga/qtgafile.cpp b/src/plugins/imageformats/tga/qtgafile.cpp index 2bdc704..3f476c1 100644 --- a/src/plugins/imageformats/tga/qtgafile.cpp +++ b/src/plugins/imageformats/tga/qtgafile.cpp @@ -150,12 +150,14 @@ QTgaFile::QTgaFile(QIODevice *device) if (bytes != HeaderSize) { mErrorMessage = QObject::tr("Image mHeader read failed"); + device->seek(0); return; } if (mHeader[ImageType] != 2) { // TODO: should support other image types mErrorMessage = QObject::tr("Image type not supported"); + device->seek(0); return; } int bitsPerPixel = mHeader[PixelDepth]; @@ -164,11 +166,11 @@ QTgaFile::QTgaFile(QIODevice *device) { mErrorMessage = QObject::tr("Image depth not valid"); } - int curPos = mDevice->pos(); int fileBytes = mDevice->size(); if (!mDevice->seek(fileBytes - FooterSize)) { mErrorMessage = QObject::tr("Could not seek to image read footer"); + device->seek(0); return; } char footer[FooterSize]; @@ -181,9 +183,9 @@ QTgaFile::QTgaFile(QIODevice *device) { mErrorMessage = QObject::tr("Image type (non-TrueVision 2.0) not supported"); } - if (!mDevice->seek(curPos)) + if (!mDevice->seek(0)) { - mErrorMessage = QObject::tr("Could not reset to read data"); + mErrorMessage = QObject::tr("Could not reset to start position"); } } |