summaryrefslogtreecommitdiffstats
path: root/src/gui/image/qpixmap_blitter.cpp
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-09-20 15:23:03 +0200
committerQt by Nokia <qt-info@nokia.com>2011-09-20 15:49:15 +0200
commitdc4764229a3eef5c0bdbd665f2e24e59398e8c51 (patch)
treeca63b594ef3624041ed4ef58f2aab94bfc77705e /src/gui/image/qpixmap_blitter.cpp
parent3fa945ae7c20c792fc02b68ccf38d0699626195a (diff)
[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. Change-Id: Idc71add7cfd429ff5b9d0ea9908d9fff1e7ce74d Merge-request: 59 Reviewed-on: http://codereview.qt-project.org/5243 Reviewed-by: Jørgen Lind <jorgen.lind@nokia.com>
Diffstat (limited to 'src/gui/image/qpixmap_blitter.cpp')
-rw-r--r--src/gui/image/qpixmap_blitter.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp
index dc0f03abdc..25801dbd4c 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;
QBlittablePlatformPixmap::QBlittablePlatformPixmap()
- : QPlatformPixmap(QPlatformPixmap::PixmapType,BlitterClass), m_engine(0), m_blittable(0)
+ : QPlatformPixmap(QPlatformPixmap::PixmapType,BlitterClass)
#ifdef QT_BLITTER_RASTEROVERLAY
,m_rasterOverlay(0), m_unmergedCopy(0)
#endif //QT_BLITTER_RASTEROVERLAY
@@ -67,8 +67,6 @@ QBlittablePlatformPixmap::QBlittablePlatformPixmap()
QBlittablePlatformPixmap::~QBlittablePlatformPixmap()
{
- delete m_blittable;
- delete m_engine;
#ifdef QT_BLITTER_RASTEROVERLAY
delete m_rasterOverlay;
delete m_unmergedCopy;
@@ -79,25 +77,22 @@ QBlittable *QBlittablePlatformPixmap::blittable() const
{
if (!m_blittable) {
QBlittablePlatformPixmap *that = const_cast<QBlittablePlatformPixmap *>(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 QBlittablePlatformPixmap::setBlittable(QBlittable *blittable)
{
resize(blittable->size().width(),blittable->size().height());
- m_blittable = blittable;
+ m_blittable.reset(blittable);
}
void QBlittablePlatformPixmap::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 = QGuiApplication::primaryScreen()->depth();
#endif
@@ -208,9 +203,9 @@ QPaintEngine *QBlittablePlatformPixmap::paintEngine() const
{
if (!m_engine) {
QBlittablePlatformPixmap *that = const_cast<QBlittablePlatformPixmap *>(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