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

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