summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-12-13 11:02:32 (GMT)
committerJørgen Lind <jorgen.lind@nokia.com>2011-12-13 11:02:32 (GMT)
commite394dd804fa6690f6d4bd270f61ca56331cea63b (patch)
tree6fce15d3feaa3e818dd64c6c17749f588db84411 /src/gui
parent139ff0b47d5f00bf7b7eca5f7c233ad70da203c4 (diff)
downloadQt-e394dd804fa6690f6d4bd270f61ca56331cea63b.zip
Qt-e394dd804fa6690f6d4bd270f61ca56331cea63b.tar.gz
Qt-e394dd804fa6690f6d4bd270f61ca56331cea63b.tar.bz2
[blitter] Use QScopedPointer for the engine and blittable
Use the QScopedPointer to prevent memory leaks, right now the code appears to be sound but make it more clear that calling ::setBlittable will destroy the old one. Cherry-picked-from: qtbase:dc4764229a3eef5c0bdbd665f2e24e59398e8c51 Change-Id: Idc71add7cfd429ff5b9d0ea9908d9fff1e7ce74d Merge-request: 59 Reviewed-on: http://codereview.qt-project.org/5243 Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com> Merge-request: 1492 Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/image/qpixmap_blitter.cpp20
-rw-r--r--src/gui/image/qpixmap_blitter_p.h4
2 files changed, 10 insertions, 14 deletions
diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp
index 836ade7..f8fb538 100644
--- a/src/gui/image/qpixmap_blitter.cpp
+++ b/src/gui/image/qpixmap_blitter.cpp
@@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE
static int global_ser_no = 0;
QBlittablePixmapData::QBlittablePixmapData()
- : QPixmapData(QPixmapData::PixmapType,BlitterClass), m_engine(0), m_blittable(0)
+ : QPixmapData(QPixmapData::PixmapType,BlitterClass)
#ifdef QT_BLITTER_RASTEROVERLAY
,m_rasterOverlay(0), m_unmergedCopy(0)
#endif //QT_BLITTER_RASTEROVERLAY
@@ -67,8 +67,6 @@ QBlittablePixmapData::QBlittablePixmapData()
QBlittablePixmapData::~QBlittablePixmapData()
{
- delete m_blittable;
- delete m_engine;
#ifdef QT_BLITTER_RASTEROVERLAY
delete m_rasterOverlay;
delete m_unmergedCopy;
@@ -79,25 +77,23 @@ QBlittable *QBlittablePixmapData::blittable() const
{
if (!m_blittable) {
QBlittablePixmapData *that = const_cast<QBlittablePixmapData *>(this);
- that->m_blittable = this->createBlittable(QSize(w,h));
+ that->m_blittable.reset(this->createBlittable(QSize(w,h)));
}
- return m_blittable;
+ return m_blittable.data();
}
void QBlittablePixmapData::setBlittable(QBlittable *blittable)
{
resize(blittable->size().width(),blittable->size().height());
- m_blittable = blittable;
+ m_blittable.reset(blittable);
}
void QBlittablePixmapData::resize(int width, int height)
{
- delete m_blittable;
- m_blittable = 0;
- delete m_engine;
- m_engine = 0;
+ m_blittable.reset(0);
+ m_engine.reset(0);
#ifdef Q_WS_QPA
d = QApplicationPrivate::platformIntegration()->screens().at(0)->depth();
#endif
@@ -209,9 +205,9 @@ QPaintEngine *QBlittablePixmapData::paintEngine() const
{
if (!m_engine) {
QBlittablePixmapData *that = const_cast<QBlittablePixmapData *>(this);
- that->m_engine = new QBlitterPaintEngine(that);
+ that->m_engine.reset(new QBlitterPaintEngine(that));
}
- return m_engine;
+ return m_engine.data();
}
#ifdef QT_BLITTER_RASTEROVERLAY
diff --git a/src/gui/image/qpixmap_blitter_p.h b/src/gui/image/qpixmap_blitter_p.h
index 07791e5..9b809ca 100644
--- a/src/gui/image/qpixmap_blitter_p.h
+++ b/src/gui/image/qpixmap_blitter_p.h
@@ -83,8 +83,8 @@ public:
#endif //QT_BLITTER_RASTEROVERLAY
protected:
- QBlitterPaintEngine *m_engine;
- QBlittable *m_blittable;
+ QScopedPointer<QBlitterPaintEngine> m_engine;
+ QScopedPointer<QBlittable> m_blittable;
#ifdef QT_BLITTER_RASTEROVERLAY
QImage *m_rasterOverlay;