summaryrefslogtreecommitdiffstats
path: root/src/opengl/qgl_mac.mm
diff options
context:
space:
mode:
authorSarah Smith <sarah.j.smith@nokia.com>2010-08-12 07:23:27 (GMT)
committerSarah Smith <sarah.j.smith@nokia.com>2010-08-12 07:23:27 (GMT)
commit88a417b47b758d35ef67d7a73f9b9a8ef8a843e1 (patch)
tree4a7ec2f932e57afaea37273e7e727a56efbc537d /src/opengl/qgl_mac.mm
parentadd9c43407a63c28f1107b9a77e74f6f62593246 (diff)
downloadQt-88a417b47b758d35ef67d7a73f9b9a8ef8a843e1.zip
Qt-88a417b47b758d35ef67d7a73f9b9a8ef8a843e1.tar.gz
Qt-88a417b47b758d35ef67d7a73f9b9a8ef8a843e1.tar.bz2
Fix memory leak.
Mac only bug - run examples/opengl/overpainting under leak detect instrument on Mac OSX to see it. Memory leak in any application that called getProcAddress() - CFStrings have to be cleaned up if the name of the function you got them from contains the word "Create" - and we weren't doing that. Reviewed-by: Gunnar Sletta
Diffstat (limited to 'src/opengl/qgl_mac.mm')
-rw-r--r--src/opengl/qgl_mac.mm11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/opengl/qgl_mac.mm b/src/opengl/qgl_mac.mm
index 4d7532e..66fe7d3 100644
--- a/src/opengl/qgl_mac.mm
+++ b/src/opengl/qgl_mac.mm
@@ -804,17 +804,22 @@ void QGLContext::generateFontDisplayLists(const QFont & /* fnt */, int /* listBa
static CFBundleRef qt_getOpenGLBundle()
{
CFBundleRef bundle = 0;
+ CFStringRef urlString = QCFString::toCFStringRef(QLatin1String("/System/Library/Frameworks/OpenGL.framework"));
QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault,
- QCFString::toCFStringRef(QLatin1String("/System/Library/Frameworks/OpenGL.framework")), kCFURLPOSIXPathStyle, false);
+ urlString, kCFURLPOSIXPathStyle, false);
if (url)
bundle = CFBundleCreate(kCFAllocatorDefault, url);
+ CFRelease(urlString);
return bundle;
}
void *QGLContext::getProcAddress(const QString &proc) const
{
- return CFBundleGetFunctionPointerForName(QCFType<CFBundleRef>(qt_getOpenGLBundle()),
- QCFString(proc));
+ CFStringRef procName = QCFString(proc).toCFStringRef(proc);
+ void *result = CFBundleGetFunctionPointerForName(QCFType<CFBundleRef>(qt_getOpenGLBundle()),
+ procName);
+ CFRelease(procName);
+ return result;
}
#ifndef QT_MAC_USE_COCOA
/*****************************************************************************