Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37418316
en ru br
Репозитории ALT
S:4.8.7-alt25
5.1: 4.6.3-alt1.M51.1
4.1: 4.4.3-alt1.M41.1
4.0: 4.3.4-alt5.M40.1
3.0: 4.0.1-alt1
+updates:4.0.1-alt2
+backports:4.2.3-alt7.1.M30
www.altlinux.org/Changes

Группа :: Система/Библиотеки
Пакет: qt4

 Главная   Изменения   Спек   Патчи   Sources   Загрузить   Gear   Bugs and FR  Repocop 

Патч: handle-tga-files-properly.diff
Скачать


--- src/plugins/imageformats/tga/qtgafile.cpp
+++ src/plugins/imageformats/tga/qtgafile.cpp
@@ -41,6 +41,7 @@
 
 #include "qtgafile.h"
 
+#include <QtCore/QBuffer>
 #include <QtCore/QIODevice>
 #include <QtCore/QDebug>
 #include <QtCore/QDateTime>
@@ -264,3 +265,16 @@ QImage QTgaFile::readImage()
     // TODO: add processing of TGA extension information - ie TGA 2.0 files
     return im;
 }
+/**
+ * Checks if device contains a valid tga image, *without* changing device
+ * position.
+ */
+bool QTgaFile::canRead(QIODevice *device)
+{
+       QByteArray header = device->peek(HeaderSize);
+       if (header.size() < HeaderSize)
+               return false;
+       QBuffer buffer(&header);
+       QTgaFile tga(&buffer);
+       return tga.isValid();
+}
--- src/plugins/imageformats/tga/qtgafile.h
+++ src/plugins/imageformats/tga/qtgafile.h
@@ -93,6 +93,8 @@ public:
     inline QSize size() const;
     inline Compression compression() const;
 
+    static bool canRead(QIODevice *device);
+
 private:
     static inline quint16 littleEndianInt(const unsigned char *d);
 
--- src/plugins/imageformats/tga/qtgahandler.cpp
+++ src/plugins/imageformats/tga/qtgahandler.cpp
@@ -77,8 +77,7 @@ bool QTgaHandler::canRead(QIODevice *dev
         qWarning("QTgaHandler::canRead() called with no device");
         return false;
     }
-    QTgaFile tga(device);
-    return tga.isValid();
+    return QTgaFile::canRead(device);
 }
 
 bool QTgaHandler::read(QImage *image)
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin