Added some memory autorelease pools and nil'ify attribute

This commit is contained in:
Marco Antognini 2014-04-13 13:49:58 +02:00
parent 324d4a18e7
commit f6c94451fb
6 changed files with 31 additions and 0 deletions

View File

@ -35,6 +35,8 @@
////////////////////////////////////////////////////////////
+(void)processEvent
{
@autoreleasepool
{
[SFApplication sharedApplication]; // Make sure NSApp exists
NSEvent* event = nil;
@ -46,6 +48,7 @@
{
[NSApp sendEvent:event];
}
} // pool
}

View File

@ -90,7 +90,13 @@ m_window(0)
////////////////////////////////////////////////////////////
SFContext::~SFContext()
{
@autoreleasepool {
[m_context clearDrawable];
m_context = nil;
m_view = nil;
m_window = nil;
} // pool
}
@ -122,6 +128,8 @@ void SFContext::setVerticalSyncEnabled(bool enabled)
void SFContext::createContext(SFContext* shared,
unsigned int bitsPerPixel,
const ContextSettings& settings)
{
@autoreleasepool
{
// Choose the attributes of OGL context.
std::vector<NSOpenGLPixelFormatAttribute> attrs;
@ -195,6 +203,7 @@ void SFContext::createContext(SFContext* shared,
// Save the settings. (OpenGL version is updated elsewhere.)
m_settings = settings;
} // pool
}
} // namespace priv

View File

@ -293,6 +293,10 @@ BOOL isValidTextUnicode(NSEvent* event);
[self removeTrackingArea:m_trackingArea];
[self setRequesterTo:0];
m_hiddenTextView = nil;
m_silentResponder = nil;
m_trackingArea = nil;
}

View File

@ -81,6 +81,9 @@
-(void)dealloc
{
[self closeWindow];
m_view = nil;
m_oglView = nil;
}

View File

@ -254,6 +254,8 @@
[self closeWindow];
[NSMenu setMenuBarVisible:YES];
m_window = nil;
m_oglView = nil;
delete m_fullscreenMode;
}

View File

@ -48,6 +48,8 @@ namespace priv
////////////////////////////////////////////////////////////
WindowImplCocoa::WindowImplCocoa(WindowHandle handle) :
m_showCursor(true)
{
@autoreleasepool
{
// Treat the handle as it real type
id nsHandle = (__bridge id)handle;
@ -78,6 +80,7 @@ m_showCursor(true)
// Finally, set up keyboard helper
initialiseKeyboardHelper();
} // pool
}
@ -87,6 +90,8 @@ WindowImplCocoa::WindowImplCocoa(VideoMode mode,
unsigned long style,
const ContextSettings& /*settings*/) :
m_showCursor(true)
{
@autoreleasepool
{
// Transform the app process.
setUpProcess();
@ -97,18 +102,23 @@ m_showCursor(true)
// Finally, set up keyboard helper
initialiseKeyboardHelper();
} // pool
}
////////////////////////////////////////////////////////////
WindowImplCocoa::~WindowImplCocoa()
{
@autoreleasepool
{
[m_delegate closeWindow];
m_delegate = nil;
// Put the next window in front, if any.
NSArray* windows = [NSApp orderedWindows];
if ([windows count] > 0)
[[windows objectAtIndex:0] makeKeyAndOrderFront:nil];
} // pool
}