void KstViewPicture::paintSelf(KstPainter& p, const QRegion& bounds) { p.save(); if (p.type() != KstPainter::P_PRINT && p.type() != KstPainter::P_EXPORT) { if (p.makingMask()) { p.setRasterOp(Qt::OrROP); } else { const QRegion clip(clipRegion()); KstBorderedViewObject::paintSelf(p, bounds - _myClipMask); p.setClipRegion(bounds & clip); } } else { KstBorderedViewObject::paintSelf(p, bounds); } const QRect cr(contentsRectForDevice(p)); if (_image.isNull()) { // fill with X p.setBrush(QBrush(Qt::gray, Qt::SolidPattern)); p.setPen(QPen(Qt::black, 0, Qt::SolidLine)); p.drawRect(cr); p.drawLine(cr.topLeft(), cr.bottomRight()); p.drawLine(cr.topRight(), cr.bottomLeft()); } else { assert(!cr.isNull()); // Null view objects are not allowed. I want to see // how this happens so it can be fixed. if (_iCache.isNull() || _iCache.size() != cr.size()) { _iCache = _image.copy(); if (!_iCache.isNull()) { _iCache = _iCache.smoothScale(cr.size()); } } if (!_iCache.isNull()) { if (p.makingMask()) { // which indicates clipping / BW mode if (_iCache.hasAlphaBuffer()) { p.drawImage(cr.topLeft(), _iCache.createAlphaMask()); } else { p.setBrush(Qt::color1); p.drawRect(cr); } } else { p.drawImage(cr.topLeft(), _iCache); } } } p.restore(); }