src/gui/image/qpixmapfilter.cpp
branchRCL_3
changeset 8 3f74d0d4af4c
parent 4 3b1da2848fc7
child 14 c0432d11811c
--- a/src/gui/image/qpixmapfilter.cpp	Mon Mar 15 12:43:09 2010 +0200
+++ b/src/gui/image/qpixmapfilter.cpp	Thu Apr 08 14:19:33 2010 +0300
@@ -422,6 +422,9 @@
     if(d->kernelWidth<=0 || d->kernelHeight <= 0)
         return;
 
+    if (src.isNull())
+        return;
+
     QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ?
         static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0;
     QPixmapConvolutionFilter *convolutionFilter = static_cast<QPixmapConvolutionFilter*>(filter);
@@ -710,7 +713,8 @@
         radius *= qreal(0.5);
 
     Q_ASSERT(img.format() == QImage::Format_ARGB32_Premultiplied
-             || img.format() == QImage::Format_RGB32);
+             || img.format() == QImage::Format_RGB32
+             || img.format() == QImage::Format_Indexed8);
 
     // choose the alpha such that pixels at radius distance from a fully
     // saturated pixel will have an alpha component of no greater than
@@ -773,6 +777,9 @@
 
 Q_GUI_EXPORT QImage qt_halfScaled(const QImage &source)
 {
+    if (source.width() < 2 || source.height() < 2)
+        return QImage();
+
     QImage srcImage = source;
 
     if (source.format() == QImage::Format_Indexed8) {
@@ -865,7 +872,7 @@
     }
 
     qreal scale = 1;
-    if (radius >= 4) {
+    if (radius >= 4 && blurImage.width() >= 2 && blurImage.height() >= 2) {
         blurImage = qt_halfScaled(blurImage);
         scale = 2;
         radius *= qreal(0.5);
@@ -902,6 +909,9 @@
     if (!painter->isActive())
         return;
 
+    if (src.isNull())
+        return;
+
     QRectF srcRect = rect;
     if (srcRect.isNull())
         srcRect = src.rect();
@@ -1082,6 +1092,10 @@
 void QPixmapColorizeFilter::draw(QPainter *painter, const QPointF &dest, const QPixmap &src, const QRectF &srcRect) const
 {
     Q_D(const QPixmapColorizeFilter);
+
+    if (src.isNull())
+        return;
+
     QPixmapFilter *filter = painter->paintEngine() && painter->paintEngine()->isExtended() ?
         static_cast<QPaintEngineEx *>(painter->paintEngine())->pixmapFilter(type(), this) : 0;
     QPixmapColorizeFilter *colorizeFilter = static_cast<QPixmapColorizeFilter*>(filter);
@@ -1312,6 +1326,10 @@
                                    const QRectF &src) const
 {
     Q_D(const QPixmapDropShadowFilter);
+
+    if (px.isNull())
+        return;
+
     QPixmapFilter *filter = p->paintEngine() && p->paintEngine()->isExtended() ?
         static_cast<QPaintEngineEx *>(p->paintEngine())->pixmapFilter(type(), this) : 0;
     QPixmapDropShadowFilter *dropShadowFilter = static_cast<QPixmapDropShadowFilter*>(filter);