diff options
author | Jason Barron <jason.barron@nokia.com> | 2010-10-08 07:08:54 (GMT) |
---|---|---|
committer | Jason Barron <jason.barron@nokia.com> | 2010-10-08 09:33:59 (GMT) |
commit | 978416807b7e92d9317036cb4348ee172dde7d4e (patch) | |
tree | a8a3e4650dad4f2e88be1c2e31fb3a4723cff195 /src | |
parent | 4c9e2a4376a52891a21f75e2a441848234ed93c2 (diff) | |
download | Qt-978416807b7e92d9317036cb4348ee172dde7d4e.zip Qt-978416807b7e92d9317036cb4348ee172dde7d4e.tar.gz Qt-978416807b7e92d9317036cb4348ee172dde7d4e.tar.bz2 |
Fix memory leak in QPixmap::toSymbianRSgImage() when an error occurs.
In the cases where an error occured while converting a QPixmap to a
VGImage this function would return without deleting the RSgImage
pointer that it created. Fix is to use a QScopedPointer instead. Also
don't use q_check_ptr() since this isn't a CBase derived class.
In case you are wondering why I didn't use a custom deleter here so
that Close() was also called, we need to make sure that Close() is
called on the RSgImage instance before calling Close() on the driver.
Reviewed-by: mread
Diffstat (limited to 'src')
-rw-r--r-- | src/openvg/qvg_symbian.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/openvg/qvg_symbian.cpp b/src/openvg/qvg_symbian.cpp index ef0160c..a9625b2 100644 --- a/src/openvg/qvg_symbian.cpp +++ b/src/openvg/qvg_symbian.cpp @@ -228,7 +228,7 @@ void* QVGPixmapData::toNativeType(NativeType type) sgInfo.iSizeInPixels.SetSize(w, h); sgInfo.iUsage = ESgUsageBitOpenVgImage | ESgUsageBitOpenVgSurface; - RSgImage *sgImage = q_check_ptr(new RSgImage()); + QScopedPointer<RSgImage> sgImage(new RSgImage()); err = sgImage->Create(sgInfo, NULL, NULL); if (err != KErrNone) { driver.Close(); @@ -239,7 +239,7 @@ void* QVGPixmapData::toNativeType(NativeType type) EGLImageKHR eglImage = QEgl::eglCreateImageKHR(QEgl::display(), EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR, - (EGLClientBuffer)sgImage, + (EGLClientBuffer)sgImage.data(), (EGLint*)KEglImageAttribs); if (!eglImage || eglGetError() != EGL_SUCCESS) { sgImage->Close(); @@ -261,13 +261,14 @@ void* QVGPixmapData::toNativeType(NativeType type) if (vgGetError() != VG_NO_ERROR) { sgImage->Close(); - sgImage = 0; + sgImage.reset(); } + // release stuff vgDestroyImage(dstVgImage); QEgl::eglDestroyImageKHR(QEgl::display(), eglImage); driver.Close(); - return reinterpret_cast<void*>(sgImage); + return reinterpret_cast<void*>(sgImage.take()); #endif } else if (type == QPixmapData::FbsBitmap) { CFbsBitmap *bitmap = q_check_ptr(new CFbsBitmap); |