1
0
Fork 0

Add an auto-release pool wrapper to the Cocoa code

Hopefully this will address some warnings seen on Mac
This commit is contained in:
James Turner 2012-05-02 21:24:44 +01:00
parent 05588c2ee4
commit 1632c5b266

View file

@ -110,6 +110,23 @@ static void setItemShortcutFromString(NSMenuItem* item, const string& s)
}
namespace {
class CocoaAutoreleasePool
{
public:
CocoaAutoreleasePool()
{
pool = [[NSAutoreleasePool alloc] init];
}
~CocoaAutoreleasePool()
{
[pool release];
}
private:
NSAutoreleasePool* pool;
};
class CocoaEnabledListener : public SGPropertyChangeListener
{
public:
@ -120,6 +137,7 @@ namespace {
virtual void valueChanged(SGPropertyNode *node)
{
CocoaAutoreleasePool pool;
BOOL b = node->getBoolValue();
[item setEnabled:b];
}
@ -137,6 +155,7 @@ FGCocoaMenuBar::CocoaMenuBarPrivate::CocoaMenuBarPrivate()
FGCocoaMenuBar::CocoaMenuBarPrivate::~CocoaMenuBarPrivate()
{
CocoaAutoreleasePool pool;
[delegate release];
}
@ -227,6 +246,8 @@ FGCocoaMenuBar::~FGCocoaMenuBar()
void FGCocoaMenuBar::init()
{
CocoaAutoreleasePool pool;
NSMenu* mainBar = [[NSApplication sharedApplication] mainMenu];
SGPropertyNode_ptr props = fgGetNode("/sim/menubar/default",true);