Use @autoreleasepool to avoid accumulating objects

This commit is contained in:
David Capello 2017-01-10 12:24:22 -03:00
parent 0b37d23c37
commit 5ba071e760
2 changed files with 46 additions and 42 deletions

View File

@ -1,5 +1,5 @@
// SHE library
// Copyright (C) 2015-2016 David Capello
// Copyright (C) 2015-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -19,7 +19,8 @@ void OSXEventQueue::getEvent(Event& ev, bool canWait)
{
ev.setType(Event::None);
retry:;
@autoreleasepool {
retry:;
NSApplication* app = [NSApplication sharedApplication];
if (!app)
return;
@ -55,6 +56,7 @@ retry:;
goto retry;
}
}
}
}
void OSXEventQueue::queueEvent(const Event& ev)

View File

@ -1,5 +1,5 @@
// SHE library
// Copyright (C) 2012-2016 David Capello
// Copyright (C) 2012-2017 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
@ -113,6 +113,7 @@ public:
}
void updateWindow(const gfx::Rect& bounds) {
@autoreleasepool {
int scale = this->scale();
NSView* view = m_window.contentView;
[view setNeedsDisplayInRect:
@ -122,6 +123,7 @@ public:
bounds.h*scale)];
[view displayIfNeeded];
}
}
void setTranslateDeadKeys(bool state) {
OSXView* view = (OSXView*)m_window.contentView;
@ -304,7 +306,7 @@ private:
return;
bitmap.lockPixels();
{
@autoreleasepool {
NSGraphicsContext* gc = [NSGraphicsContext currentContext];
CGContextRef cg = (CGContextRef)[gc graphicsPort];
CGColorSpaceRef colorSpace = CGDisplayCopyColorSpace(CGMainDisplayID());