add: if (pen.style () != Qt::NoPen || brush.style () != Qt::NoBrush) { painter.begin (&pixmap); painter.setPen (pen); painter.setBrush (brush); }  #define PAINTER_CALL(cmd)         \ {                                 \ if (painter.isActive ())      \ painter . cmd ;           \ \ if (maskPainter.isActive ())  \ maskPainter . cmd ;       \ }  if (startPoint != endPoint) { #if DEBUG_KP_TOOL_RECTANGLE && 1 kdDebug () << "\tdraw shape" << endl; #endif  switch (mode) { case kpToolRectangle::Rectangle: PAINTER_CALL (drawRect (QRect (startPoint - rect.topLeft (), endPoint - rect.topLeft ()))); break; case kpToolRectangle::RoundedRectangle: PAINTER_CALL (drawRoundRect (QRect (startPoint - rect.topLeft (), endPoint - rect.topLeft ()))); break; case kpToolRectangle::Ellipse: PAINTER_CALL (drawEllipse (QRect (startPoint - rect.topLeft (), endPoint - rect.topLeft ()))); break; default: kdError () << "kptoolrectangle.cpp::pixmap() passed unknown mode: " << int (mode) << endl; break; } } else { #if DEBUG_KP_TOOL_RECTANGLE && 1 kdDebug () << "\tstartPoint == endPoint" << endl; #endif    PAINTER_CALL (drawPoint (startPoint - rect.topLeft ())); } #undef PAINTER_CALL  if (painter.isActive ()) painter.end ();  if (maskPainter.isActive ()) maskPainter.end ();  if (!maskBitmap.isNull ()) pixmap.setMask (maskBitmap);
context: static QPixmap pixmap (const kpToolRectangle::Mode mode,                       kpDocument *document, const QRect &rect,                       const QPoint &startPoint, const QPoint &endPoint,                       const QPen &pen, const QBrush &brush){    QPixmap pixmap = document->getPixmapAt (rect);    QPainter painter (&pixmap);    painter.setPen (pen);    painter.setBrush (brush);    switch (mode)    {    case kpToolRectangle::Rectangle:        painter.drawRect (QRect (startPoint - rect.topLeft (), endPoint - rect.topLeft ()));        break;    case kpToolRectangle::RoundedRectangle:        painter.drawRoundRect (QRect (startPoint - rect.topLeft (), endPoint - rect.topLeft ()));        break;    case kpToolRectangle::Ellipse:        painter.drawEllipse (QRect (startPoint - rect.topLeft (), endPoint - rect.topLeft ()));        break;    default:        kdError () << "kptoolrectangle.cpp::pixmap() passed unknown mode: " << int (mode) << endl;        break;    }    return pixmap;}