From 785767e1f965a904765bab5dbfff1a21240dcc88 Mon Sep 17 00:00:00 2001 From: Pierre Rossi Date: Thu, 7 Jan 2010 20:15:14 +0100 Subject: Fix a painter warning when using a treewidget with animations in a splitter and the tree is collapsed, and then select an item in the tree that requires expanding, it might end up trying to paint to an invalid pixmap Reviewed-by: Gabi --- src/gui/itemviews/qtreeview.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index bcf9cfb..bf88a75 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -3064,6 +3064,8 @@ QPixmap QTreeViewPrivate::renderTreeToPixmapForAnimation(const QRect &rect) cons { Q_Q(const QTreeView); QPixmap pixmap(rect.size()); + if (rect.size().isEmpty()) + return pixmap; pixmap.fill(Qt::transparent); //the base might not be opaque, and we don't want uninitialized pixels. QPainter painter(&pixmap); painter.fillRect(QRect(QPoint(0,0), rect.size()), q->palette().base()); -- cgit v0.12 From 1484008e831a6b18272babb17992c4de686da045 Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 8 Jan 2010 10:57:43 +0100 Subject: Make sure the rect in QPixmap::copy() doesn't exceed the boundingRect. Task: http://bugreports.qt.nokia.com/browse/QTBUG-6303 Reviewed-by: Samuel --- src/gui/image/qpixmap.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 7e4597e..7b522f5 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -357,7 +357,9 @@ QPixmap QPixmap::copy(const QRect &rect) const if (isNull()) return QPixmap(); - const QRect r = rect.isEmpty() ? QRect(0, 0, width(), height()) : rect; + QRect r(0, 0, width(), height()); + if (!rect.isEmpty()) + r = r.intersected(rect); QPixmapData *d = data->createCompatiblePixmapData(); d->copy(data.data(), r); -- cgit v0.12