summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorMorten Johan Sørvig <morten.sorvig@nokia.com>2011-12-12 09:52:40 +0100
committerQt by Nokia <qt-info@nokia.com>2011-12-12 17:27:19 +0100
commit82b73ab03a7f2f519ad8efd176a8f3be7a9b9f5b (patch)
treef7a1f0c78dc02e53aa49027fbefb0288b171fb77 /src/plugins
parent6802e3165ea0d7c7bb5b4249ef1bb82f85febf86 (diff)
Cocoa: Add autorelease pools.
A couple of cases where we call Cococa APIs without having an autorelease pool in place surfaced after removing the global autorelease pool in 1a218a7. (This happens when when Qt API is called before app.exec() has started the Cocoa event loop.) Add local autorelease pools to prevent memory leaks. Change-Id: I0c4be3ff102aaff4539235857f95ab29fdbc9d70 Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/cocoa/qcocoabackingstore.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm5
3 files changed, 9 insertions, 0 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoabackingstore.mm b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
index 0cde19644e..d278392409 100644
--- a/src/plugins/platforms/cocoa/qcocoabackingstore.mm
+++ b/src/plugins/platforms/cocoa/qcocoabackingstore.mm
@@ -40,6 +40,7 @@
****************************************************************************/
#include "qcocoabackingstore.h"
+#include "qcocoaautoreleasepool.h"
#include <QtCore/qdebug.h>
#include <QtGui/QPainter>
@@ -80,6 +81,7 @@ void QCocoaBackingStore::flush(QWindow *widget, const QRegion &region, const QPo
{
Q_UNUSED(widget);
Q_UNUSED(offset);
+ QCocoaAutoReleasePool pool;
QRect geo = region.boundingRect();
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index 6d7770fecc..03348bb434 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -90,6 +90,8 @@ QCocoaIntegration::QCocoaIntegration()
: mFontDb(new QCoreTextFontDatabase())
, mEventDispatcher(new QCocoaEventDispatcher())
{
+ QCocoaAutoReleasePool pool;
+
qApp->setAttribute(Qt::AA_DontUseNativeMenuBar, false);
NSApplication *cocoaApplication = [NSApplication sharedApplication];
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index de38db5fab..86db8a5f67 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -129,6 +129,7 @@ void QCocoaWindow::setGeometry(const QRect &rect)
void QCocoaWindow::setVisible(bool visible)
{
+ QCocoaAutoReleasePool pool;
if (visible) {
// The parent window might have moved while this window was hidden,
// update the window geometry if there is a parent.
@@ -146,6 +147,8 @@ void QCocoaWindow::setVisible(bool visible)
void QCocoaWindow::setWindowTitle(const QString &title)
{
+ QCocoaAutoReleasePool pool;
+
CFStringRef windowTitle = QCFString::toCFStringRef(title);
[m_nsWindow setTitle: const_cast<NSString *>(reinterpret_cast<const NSString *>(windowTitle))];
CFRelease(windowTitle);
@@ -164,6 +167,8 @@ void QCocoaWindow::lower()
void QCocoaWindow::propagateSizeHints()
{
+ QCocoaAutoReleasePool pool;
+
[m_nsWindow setMinSize : qt_mac_toNSSize(window()->minimumSize())];
[m_nsWindow setMaxSize : qt_mac_toNSSize(window()->maximumSize())];