From 260a040477e862e7fe2a04847df3c3c3c5d3871a Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Fri, 26 Oct 2007 16:35:58 +0000 Subject: [PATCH] * avoid a couple unecessary vars/method calls * don't try and paint on a null pixmap svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=729679 --- widgets/widget.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/widgets/widget.cpp b/widgets/widget.cpp index 5c93fc470..1b8c6cba3 100644 --- a/widgets/widget.cpp +++ b/widgets/widget.cpp @@ -307,9 +307,12 @@ void Widget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW { painter->setOpacity(d->opacity); + /* +NOTE: put this back if we end up needing to control when things paint due to, e.g. zooming. if (!d->shouldPaint(painter, transform())) { return; } + */ if (d->cachePaintMode == NoCacheMode) { paintWidget(painter, option, widget); @@ -318,7 +321,6 @@ void Widget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW // Cached painting QRectF brect = boundingRect(); - QRect boundingRectInt = brect.toRect(); // Fetch the off-screen transparent buffer and exposed area info. QPixmap pix; @@ -375,6 +377,12 @@ void Widget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW QTransform transform = painter->worldTransform(); QRect deviceRect = transform.mapRect(brect).toRect(); + if (deviceRect.width() < 1 || + deviceRect.height() < 1) { + // we have nothing to paint! + return; + } + // Auto-adjust the pixmap size. if (deviceRect.size() != pix.size()) { pix = QPixmap(deviceRect.size());