diff options
author | Harald Fernengel <harald@trolltech.com> | 2009-08-13 13:31:02 (GMT) |
---|---|---|
committer | Harald Fernengel <harald@trolltech.com> | 2009-08-13 13:31:41 (GMT) |
commit | 6d2a1051970a417c4e60375cb43f06751da57728 (patch) | |
tree | a9a4b3a0d7bf5ad8be8074ca8c4d9b932946db37 /src/gui/image/qbitmap.cpp | |
parent | 7bce80068d1e8cc54ac129abb53545d6fad69bc1 (diff) | |
download | Qt-6d2a1051970a417c4e60375cb43f06751da57728.zip Qt-6d2a1051970a417c4e60375cb43f06751da57728.tar.gz Qt-6d2a1051970a417c4e60375cb43f06751da57728.tar.bz2 |
Use QScopedPointer wherever possible
Ensures that we don't leak when creating a new Pixmap while running out
of memory
Diffstat (limited to 'src/gui/image/qbitmap.cpp')
-rw-r--r-- | src/gui/image/qbitmap.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/src/gui/image/qbitmap.cpp b/src/gui/image/qbitmap.cpp index a1497bc..5827dc1 100644 --- a/src/gui/image/qbitmap.cpp +++ b/src/gui/image/qbitmap.cpp @@ -265,15 +265,12 @@ QBitmap QBitmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) img.setColor(1, c0); } - QPixmapData *d; QGraphicsSystem* gs = QApplicationPrivate::graphicsSystem(); - if (gs) - d = gs->createPixmapData(QPixmapData::BitmapType); - else - d = QGraphicsSystem::createDefaultPixmapData(QPixmapData::BitmapType); + QScopedPointer<QPixmapData> data(gs ? gs->createPixmapData(QPixmapData::BitmapType) + : QGraphicsSystem::createDefaultPixmapData(QPixmapData::BitmapType)); - d->fromImage(img, flags | Qt::MonoOnly); - return QPixmap(d); + data->fromImage(img, flags | Qt::MonoOnly); + return QPixmap(data.take()); } /*! |