summaryrefslogtreecommitdiffstats
path: root/src/gui/painting
diff options
context:
space:
mode:
authorGunnar Sletta <gunnar@trolltech.com>2009-09-28 11:25:41 (GMT)
committerGunnar Sletta <gunnar@trolltech.com>2009-09-28 11:29:59 (GMT)
commitdb032c025f56d2137b96e49fd817cae35dd5c8a3 (patch)
treec125c88fa1d0407b29bb11cec6bd57f1d0d88b65 /src/gui/painting
parent587c004ce82844980c679547f86109174cbe6202 (diff)
downloadQt-db032c025f56d2137b96e49fd817cae35dd5c8a3.zip
Qt-db032c025f56d2137b96e49fd817cae35dd5c8a3.tar.gz
Qt-db032c025f56d2137b96e49fd817cae35dd5c8a3.tar.bz2
Deep copy QImage based on non-owned data so we can safely store them
Reviewed-by: Samuel
Diffstat (limited to 'src/gui/painting')
-rw-r--r--src/gui/painting/qpaintbuffer.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp
index 57e7cd0..6b9d77c 100644
--- a/src/gui/painting/qpaintbuffer.cpp
+++ b/src/gui/painting/qpaintbuffer.cpp
@@ -44,6 +44,7 @@
//#include <private/qtextengine_p.h>
#include <private/qfontengine_p.h>
#include <private/qemulationpaintengine_p.h>
+#include <private/qimage_p.h>
#include <QDebug>
@@ -892,6 +893,12 @@ void QPaintBufferEngine::drawPixmap(const QPointF &pos, const QPixmap &pm)
buffer->updateBoundingRect(QRectF(pos, pm.size()));
}
+static inline QImage qpaintbuffer_storable_image(const QImage &src)
+{
+ QImageData *d = const_cast<QImage &>(src).data_ptr();
+ return d->own_data ? src : src.copy();
+}
+
void QPaintBufferEngine::drawImage(const QRectF &r, const QImage &image, const QRectF &sr,
Qt::ImageConversionFlags /*flags */)
{
@@ -899,7 +906,8 @@ void QPaintBufferEngine::drawImage(const QRectF &r, const QImage &image, const Q
qDebug() << "QPaintBufferEngine: drawImage: src/dest rects " << r << sr;
#endif
QPaintBufferCommand *cmd =
- buffer->addCommand(QPaintBufferPrivate::Cmd_DrawPixmapRect, QVariant(image));
+ buffer->addCommand(QPaintBufferPrivate::Cmd_DrawImageRect,
+ QVariant(qpaintbuffer_storable_image(image)));
cmd->extra = buffer->addData((qreal *) &r, 4);
buffer->addData((qreal *) &sr, 4);
// ### flags...
@@ -913,7 +921,8 @@ void QPaintBufferEngine::drawImage(const QPointF &pos, const QImage &image)
qDebug() << "QPaintBufferEngine: drawImage: pos:" << pos;
#endif
QPaintBufferCommand *cmd =
- buffer->addCommand(QPaintBufferPrivate::Cmd_DrawImagePos, QVariant(image));
+ buffer->addCommand(QPaintBufferPrivate::Cmd_DrawImagePos,
+ QVariant(qpaintbuffer_storable_image(image)));
cmd->extra = buffer->addData((qreal *) &pos, 2);
if (buffer->calculateBoundingRect)
buffer->updateBoundingRect(QRectF(pos, image.size()));