summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/image/qimage.cpp6
-rw-r--r--tests/auto/qpixmap/tst_qpixmap.cpp29
2 files changed, 35 insertions, 0 deletions
diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp
index d48d427..0358ba0 100644
--- a/src/gui/image/qimage.cpp
+++ b/src/gui/image/qimage.cpp
@@ -2904,6 +2904,12 @@ static void convert_Indexed8_to_X32(QImageData *dest, const QImageData *src, Qt:
Q_ASSERT(src->height == dest->height);
QVector<QRgb> colorTable = fix_color_table(src->colortable, dest->format);
+ if (colorTable.size() == 0) {
+ colorTable.resize(256);
+ for (int i=0; i<256; ++i)
+ colorTable[i] = qRgb(i, i, i);
+
+ }
int w = src->width;
const uchar *src_data = src->data;
diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp
index 8dd5f5f..9422327 100644
--- a/tests/auto/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/qpixmap/tst_qpixmap.cpp
@@ -83,6 +83,9 @@ private slots:
void fromImage_data();
void fromImage();
+ void fromUninitializedImage_data();
+ void fromUninitializedImage();
+
void convertFromImage_data();
void convertFromImage();
@@ -266,6 +269,32 @@ void tst_QPixmap::fromImage()
QCOMPARE(result, image);
}
+
+void tst_QPixmap::fromUninitializedImage_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+
+ QTest::newRow("Format_Mono") << QImage::Format_Mono;
+ QTest::newRow("Format_MonoLSB") << QImage::Format_MonoLSB;
+ QTest::newRow("Format_Indexed8") << QImage::Format_Indexed8;
+ QTest::newRow("Format_RGB32") << QImage::Format_RGB32;
+ QTest::newRow("Format_ARGB32") << QImage::Format_ARGB32;
+ QTest::newRow("Format_ARGB32_Premultiplied") << QImage::Format_ARGB32_Premultiplied;
+ QTest::newRow("Format_RGB16") << QImage::Format_RGB16;
+}
+
+void tst_QPixmap::fromUninitializedImage()
+{
+ QFETCH(QImage::Format, format);
+
+ QImage image(100, 100, format);
+ QPixmap pix = QPixmap::fromImage(image);
+
+ // it simply shouldn't crash...
+ QVERIFY(true);
+
+}
+
void tst_QPixmap::convertFromImage_data()
{
QTest::addColumn<QImage>("img1");