summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Anokhin <alexander@anokhin.me>2012-03-15 12:05:31 +0400
committerQt by Nokia <qt-info@nokia.com>2012-03-20 00:42:58 +0100
commitbfbfbb8ae1a52de8ebe4d718fe1dd2e2234b8c89 (patch)
tree7265302f0e033c62e09b078f767c8f72533c2a0b
parent68b1d5c17aa38d5921bdade2b0e0cb67c6c90513 (diff)
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>
-rw-r--r--src/plugins/imageformats/tga/qtgafile.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/plugins/imageformats/tga/qtgafile.cpp b/src/plugins/imageformats/tga/qtgafile.cpp
index 2bdc7044c9..3f476c1069 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");
}
}