diff options
author | Jani Hautakangas <jani.hautakangas@nokia.com> | 2011-01-18 08:59:34 (GMT) |
---|---|---|
committer | Jani Hautakangas <jani.hautakangas@nokia.com> | 2011-01-18 10:21:31 (GMT) |
commit | b928bab9dde43cf3acace6dfae0ae6a4f6649650 (patch) | |
tree | 0a51bb8d2071a94b3e629f8c5df87b4275a22438 /src | |
parent | c756d5cffdc31228b9ab9388c307bf4eb705b923 (diff) | |
download | Qt-b928bab9dde43cf3acace6dfae0ae6a4f6649650.zip Qt-b928bab9dde43cf3acace6dfae0ae6a4f6649650.tar.gz Qt-b928bab9dde43cf3acace6dfae0ae6a4f6649650.tar.bz2 |
Fix to data detaching in OpenVG pixmap data
QImage::converToFormat(format) won't detach QImage if
format stays the same. Because of this, internal QImage
buffer of QVGPixmapData was not deep copied. Drawing
to QPixmap target modified the original QImage that was
used to create QPixmap and in some cases crashed because
paint engine referred to wrong target.
Task-number: QT-4407
Reviewed-by: Jason Barron
Diffstat (limited to 'src')
-rw-r--r-- | src/openvg/qpixmapdata_vg.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp index e4b1d02..732b484 100644 --- a/src/openvg/qpixmapdata_vg.cpp +++ b/src/openvg/qpixmapdata_vg.cpp @@ -200,6 +200,9 @@ bool QVGPixmapData::fromData(const uchar *buffer, uint len, const char *format, return !isNull(); } +/*! + out-of-place conversion (inPlace == false) will always detach() + */ void QVGPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags flags, bool inPlace) { if (image.size() == QSize(w, h)) @@ -216,11 +219,16 @@ void QVGPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags else format = image.hasAlphaChannel() ? sourceFormat() : QImage::Format_RGB32; - if (inPlace && image.data_ptr()->convertInPlace(format, flags)) + if (inPlace && image.data_ptr()->convertInPlace(format, flags)) { source = image; - else + } else { source = image.convertToFormat(format); + // convertToFormat won't detach the image if format stays the same. + if (image.format() == format) + source.detach(); + } + recreate = true; } |