Blame SOURCES/qt-everywhere-opensource-src-4.8.1-qtgahandle.patch

462c49
diff -up qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.cpp.me qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.cpp
462c49
--- qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.cpp.me	2012-03-30 21:54:59.921331145 +0200
462c49
+++ qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.cpp	2012-03-30 21:58:14.516042067 +0200
462c49
@@ -41,6 +41,7 @@
462c49
 
462c49
 #include "qtgafile.h"
462c49
 
462c49
+#include <QtCore/QBuffer>
462c49
 #include <QtCore/QIODevice>
462c49
 #include <QtCore/QDebug>
462c49
 #include <QtCore/QDateTime>
462c49
@@ -264,3 +265,16 @@ QImage QTgaFile::readImage()
462c49
     // TODO: add processing of TGA extension information - ie TGA 2.0 files
462c49
     return im;
462c49
 }
462c49
+/**
462c49
+ * Checks if device contains a valid tga image, *without* changing device
462c49
+ * position.
462c49
+ */
462c49
+bool QTgaFile::canRead(QIODevice *device)
462c49
+{
462c49
+	QByteArray header = device->peek(HeaderSize);
462c49
+	if (header.size() < HeaderSize)
462c49
+		return false;
462c49
+	QBuffer buffer(&header);
462c49
+	QTgaFile tga(&buffer);
462c49
+	return tga.isValid();
462c49
+}
462c49
diff -up qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.h.me qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.h
462c49
--- qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.h.me	2012-03-30 21:58:39.670023189 +0200
462c49
+++ qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgafile.h	2012-03-30 21:59:06.202317384 +0200
462c49
@@ -93,6 +93,8 @@ public:
462c49
     inline QSize size() const;
462c49
     inline Compression compression() const;
462c49
 
462c49
+    static bool canRead(QIODevice *device);
462c49
+
462c49
 private:
462c49
     static inline quint16 littleEndianInt(const unsigned char *d);
462c49
 
462c49
diff -up qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgahandler.cpp.me qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgahandler.cpp
462c49
--- qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgahandler.cpp.me	2012-03-30 21:59:17.373303356 +0200
462c49
+++ qt-everywhere-opensource-src-4.8.1/src/plugins/imageformats/tga/qtgahandler.cpp	2012-03-30 22:00:13.817226439 +0200
462c49
@@ -77,8 +77,7 @@ bool QTgaHandler::canRead(QIODevice *dev
462c49
         qWarning("QTgaHandler::canRead() called with no device");
462c49
         return false;
462c49
     }
462c49
-    QTgaFile tga(device);
462c49
-    return tga.isValid();
462c49
+    return QTgaFile::canRead(device);
462c49
 }
462c49
 
462c49
 bool QTgaHandler::read(QImage *image)