From 8ea7bc92650e8e4c74e5ec2bbf05ef2b33107ee8 Mon Sep 17 00:00:00 2001 From: Jason Barron Date: Fri, 14 Aug 2009 15:13:56 +0200 Subject: Fix incorrect logic in QPixmap::fromSymbianCFbsBitmap. In some alternate universes it might make sense to use a pointer before checking if it is valid, but since this isn't one we shoudn't do it. Also extend the autotest a little to make sure we catch this case. --- src/gui/image/qpixmap_s60.cpp | 5 ++++- tests/auto/qpixmap/tst_qpixmap.cpp | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gui/image/qpixmap_s60.cpp b/src/gui/image/qpixmap_s60.cpp index 58b3ee4..ab19924 100644 --- a/src/gui/image/qpixmap_s60.cpp +++ b/src/gui/image/qpixmap_s60.cpp @@ -202,10 +202,13 @@ return a null QPixmap. QPixmap QPixmap::fromSymbianCFbsBitmap(CFbsBitmap *bitmap) { + if (!bitmap) + return QPixmap(); + int width = bitmap->SizeInPixels().iWidth; int height = bitmap->SizeInPixels().iHeight; - if (!bitmap || width <= 0 || height <= 0 || bitmap->IsCompressedInRAM()) + if (width <= 0 || height <= 0 || bitmap->IsCompressedInRAM()) return QPixmap(); TDisplayMode displayMode = bitmap->DisplayMode(); diff --git a/tests/auto/qpixmap/tst_qpixmap.cpp b/tests/auto/qpixmap/tst_qpixmap.cpp index 7321fe9..35d4cf3 100644 --- a/tests/auto/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/qpixmap/tst_qpixmap.cpp @@ -1011,6 +1011,14 @@ void tst_QPixmap::fromSymbianCFbsBitmap() bitmapContext->Clear(); __UHEAP_MARK; + { // Test the null case + CFbsBitmap *bitmap = 0; + QPixmap pixmap = QPixmap::fromSymbianCFbsBitmap(bitmap); + QVERIFY(pixmap.isNull()); + } + __UHEAP_MARKEND; + + __UHEAP_MARK; { // Test the normal case QPixmap pixmap = QPixmap::fromSymbianCFbsBitmap(nativeBitmap); // QCOMPARE(pixmap.depth(), expectedDepth); // Depth is not preserved now -- cgit v0.12