summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKim Motoyoshi Kalland <kim.kalland@nokia.com>2009-10-09 13:50:16 (GMT)
committerKim Motoyoshi Kalland <kim.kalland@nokia.com>2009-10-09 14:07:11 (GMT)
commit9e3bbc70ef6bd383435bf8d46165050a87f05d55 (patch)
treeec9385622bd3372eb53c54ca405d4e659a208b89 /src
parentf74570b72bd71f3747521a5f561971165f3297e5 (diff)
downloadQt-9e3bbc70ef6bd383435bf8d46165050a87f05d55.zip
Qt-9e3bbc70ef6bd383435bf8d46165050a87f05d55.tar.gz
Qt-9e3bbc70ef6bd383435bf8d46165050a87f05d55.tar.bz2
Fixed bug where calling fill on pixmap with active painter would crash.
Calling QPixmap::fill() on a pixmap may in some cases cause the painter's paint engine pointer to become stale. A subsequent call to the painter would therefore crash. Now, QPixmap::fill() will print a warning and return in those cases. I also added a warning in the documentation of QPixmap::fill(). Task-number: QTBUG-2832 Reviewed-by: Trond
Diffstat (limited to 'src')
-rw-r--r--src/gui/image/qpixmap.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp
index 558ae54..8133cc0 100644
--- a/src/gui/image/qpixmap.cpp
+++ b/src/gui/image/qpixmap.cpp
@@ -947,6 +947,9 @@ bool QPixmap::doImageIO(QImageWriter *writer, int quality) const
/*!
Fills the pixmap with the given \a color.
+ The effect of this function is undefined when the pixmap is
+ being painted on.
+
\sa {QPixmap#Pixmap Transformations}{Pixmap Transformations}
*/
@@ -955,6 +958,13 @@ void QPixmap::fill(const QColor &color)
if (isNull())
return;
+ // Some people are probably already calling fill while a painter is active, so to not break
+ // their programs, only print a warning and return when the fill operation could cause a crash.
+ if (paintingActive() && (color.alpha() != 255) && !hasAlphaChannel()) {
+ qWarning("QPixmap::fill: Cannot fill while pixmap is being painted on");
+ return;
+ }
+
detach();
data->fill(color);
}