File 0264-fix-zero-height-qpixmap-isnull.diff of Package libqt4

Trolltech task ID : 240752
bugs.kde.org number : 179978
applied: yes
author: Alex Merry <kde@randomguy3.me.uk>
os: unix

QPixmap::isNull() depends on the width of the pixmap being set to 0
when either the height or width parameters passed in were 0.  But, on
X11 at least, this doesn't happen.  This patch fixes that.

Fixed in Qt 4.5 (identical fix, apart from the assigment is done in two lines).

Test case:
==============================
#include <QApplication>
#include <QDebug>
#include <QPixmap>

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QPixmap pm1(0, 8);
    qWarning() << "Zero-width pixmap isNull():" << pm1.isNull();
    QPixmap pm2(8, 0);
    qWarning() << "Zero-height pixmap isNull():" << pm2.isNull();
    return 0;
}
==============================
Test case result (without patch):
> Zero-width pixmap isNull(): true
> Zero-height pixmap isNull(): false
==============================



Index: src/gui/image/qpixmap_x11.cpp
===================================================================
--- src/gui/image/qpixmap_x11.cpp	(revision 906157)
+++ src/gui/image/qpixmap_x11.cpp	(working copy)
@@ -320,6 +320,7 @@ void QX11PixmapData::resize(int width, i
     if (make_null || w < 0 || h < 0 || d == 0) {
         hd = 0;
         picture = 0;
+        w = h = 0;
         if (!make_null)
             qWarning("QPixmap: Invalid pixmap parameters");
         return;
openSUSE Build Service is sponsored by