OSX: fix leaks due to missing NSAutoreleasePool
env OBJC_DEBUG_MISSING_POOLS=YES qtcreator Change-Id: Ibbe5f42af5b94a439be3f0dd0f2b6e34bb1afd3f Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>bb10
parent
b7d4e4ffeb
commit
9608629d7e
|
|
@ -44,6 +44,18 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace {
|
||||
class AutoReleasePool
|
||||
{
|
||||
public:
|
||||
AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {}
|
||||
~AutoReleasePool() { [pool release]; }
|
||||
|
||||
private:
|
||||
NSAutoreleasePool *pool;
|
||||
};
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
** Wrappers for Mac locale system functions
|
||||
*/
|
||||
|
|
@ -414,6 +426,7 @@ QLocale QSystemLocale::fallbackUiLocale() const
|
|||
|
||||
QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
|
||||
{
|
||||
AutoReleasePool pool;
|
||||
switch(type) {
|
||||
// case Name:
|
||||
// return getMacLocaleName();
|
||||
|
|
|
|||
|
|
@ -48,6 +48,18 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
namespace {
|
||||
class AutoReleasePool
|
||||
{
|
||||
public:
|
||||
AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {}
|
||||
~AutoReleasePool() { [pool release]; }
|
||||
|
||||
private:
|
||||
NSAutoreleasePool *pool;
|
||||
};
|
||||
}
|
||||
|
||||
// this could become a list of all languages used for each writing
|
||||
// system, instead of using the single most common language.
|
||||
static const char *languageForWritingSystem[] = {
|
||||
|
|
@ -439,6 +451,8 @@ QStringList QCoreTextFontDatabase::fallbacksForFamily(const QString &family, QFo
|
|||
Q_UNUSED(style);
|
||||
Q_UNUSED(script);
|
||||
|
||||
AutoReleasePool pool;
|
||||
|
||||
static QHash<QString, QStringList> fallbackLists;
|
||||
|
||||
if (!family.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -630,6 +630,7 @@ QString qt_mac_applicationName()
|
|||
|
||||
int qt_mac_mainScreenHeight()
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
// The first screen in the screens array is documented
|
||||
// to have the (0,0) origin.
|
||||
NSRect screenFrame = [[[NSScreen screens] firstObject] frame];
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "qcocoaintegration.h"
|
||||
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
#include "qcocoawindow.h"
|
||||
#include "qcocoabackingstore.h"
|
||||
#include "qcocoanativeinterface.h"
|
||||
|
|
@ -136,6 +137,7 @@ void QCocoaScreen::updateGeometry()
|
|||
|
||||
qreal QCocoaScreen::devicePixelRatio() const
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
NSScreen * screen = osScreen();
|
||||
return qreal(screen ? [screen backingScaleFactor] : 1.0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,6 +217,8 @@ QCocoaMenu::QCocoaMenu() :
|
|||
m_menuBar(0),
|
||||
m_containingMenuItem(0)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
|
||||
m_delegate = [[QCocoaMenuDelegate alloc] initWithMenu:this];
|
||||
m_nativeItem = [[NSMenuItem alloc] initWithTitle:@"" action:nil keyEquivalent:@""];
|
||||
m_nativeMenu = [[NSMenu alloc] initWithTitle:@"Untitled"];
|
||||
|
|
|
|||
|
|
@ -145,6 +145,8 @@ void QCocoaMenuBar::removeMenu(QPlatformMenu *platformMenu)
|
|||
|
||||
void QCocoaMenuBar::syncMenu(QPlatformMenu *menu)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
|
||||
QCocoaMenu *cocoaMenu = static_cast<QCocoaMenu *>(menu);
|
||||
Q_FOREACH (QCocoaMenuItem *item, cocoaMenu->items())
|
||||
cocoaMenu->syncMenuItem(item);
|
||||
|
|
|
|||
|
|
@ -99,6 +99,8 @@ QCocoaMenuItem::QCocoaMenuItem() :
|
|||
|
||||
QCocoaMenuItem::~QCocoaMenuItem()
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
|
||||
if (m_menu && COCOA_MENU_ANCESTOR(m_menu) == this)
|
||||
SET_COCOA_MENU_ANCESTOR(m_menu, 0);
|
||||
if (m_merged) {
|
||||
|
|
|
|||
|
|
@ -234,6 +234,7 @@ void QCocoaNativeInterface::registerDraggedTypes(const QStringList &types)
|
|||
|
||||
void QCocoaNativeInterface::setDockMenu(QPlatformMenu *platformMenu)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
QCocoaMenu *cocoaPlatformMenu = static_cast<QCocoaMenu *>(platformMenu);
|
||||
NSMenu *menu = cocoaPlatformMenu->nsMenu();
|
||||
[NSApp QT_MANGLE_NAMESPACE(qt_setDockMenu): menu];
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "qcocoasystemsettings.h"
|
||||
|
||||
#include "qcocoaautoreleasepool.h"
|
||||
#include "qcocoahelpers.h"
|
||||
|
||||
#include <QtCore/private/qcore_mac_p.h>
|
||||
|
|
@ -44,6 +45,8 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
QColor qt_mac_colorForTheme(ThemeBrush brush)
|
||||
{
|
||||
QCocoaAutoReleasePool pool;
|
||||
|
||||
QCFType<CGColorRef> cgClr = 0;
|
||||
HIThemeBrushCreateCGColor(brush, &cgClr);
|
||||
return qt_mac_toQColor(cgClr);
|
||||
|
|
|
|||
|
|
@ -93,6 +93,18 @@
|
|||
|
||||
QT_USE_NAMESPACE
|
||||
|
||||
namespace {
|
||||
class AutoReleasePool
|
||||
{
|
||||
public:
|
||||
AutoReleasePool(): pool([[NSAutoreleasePool alloc] init]) {}
|
||||
~AutoReleasePool() { [pool release]; }
|
||||
|
||||
private:
|
||||
NSAutoreleasePool *pool;
|
||||
};
|
||||
}
|
||||
|
||||
@interface QT_MANGLE_NAMESPACE(NotificationReceiver) : NSObject {
|
||||
QMacStylePrivate *mPrivate;
|
||||
}
|
||||
|
|
@ -2122,6 +2134,8 @@ QMacStyle::QMacStyle()
|
|||
: QCommonStyle(*new QMacStylePrivate)
|
||||
{
|
||||
Q_D(QMacStyle);
|
||||
AutoReleasePool pool;
|
||||
|
||||
d->receiver = [[NotificationReceiver alloc] initWithPrivate:d];
|
||||
NotificationReceiver *receiver = static_cast<NotificationReceiver *>(d->receiver);
|
||||
|
||||
|
|
@ -2137,6 +2151,8 @@ QMacStyle::QMacStyle()
|
|||
QMacStyle::~QMacStyle()
|
||||
{
|
||||
Q_D(QMacStyle);
|
||||
AutoReleasePool pool;
|
||||
|
||||
[reinterpret_cast<NSScroller*>(d->nsscroller) release];
|
||||
|
||||
NotificationReceiver *receiver = static_cast<NotificationReceiver *>(d->receiver);
|
||||
|
|
@ -2152,6 +2168,7 @@ QMacStyle::~QMacStyle()
|
|||
*/
|
||||
QPixmap QMacStylePrivate::generateBackgroundPattern() const
|
||||
{
|
||||
AutoReleasePool pool;
|
||||
QPixmap px(4, 4);
|
||||
QMacCGContext cg(&px);
|
||||
HIThemeSetFill(kThemeBrushDialogBackgroundActive, 0, cg, kHIThemeOrientationNormal);
|
||||
|
|
@ -2749,6 +2766,8 @@ QPalette QMacStyle::standardPalette() const
|
|||
int QMacStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w,
|
||||
QStyleHintReturn *hret) const
|
||||
{
|
||||
AutoReleasePool pool;
|
||||
|
||||
SInt32 ret = 0;
|
||||
switch (sh) {
|
||||
case SH_Slider_SnapToValue:
|
||||
|
|
|
|||
Loading…
Reference in New Issue