OS X: Fix a few memory leaks.

This commit is contained in:
C.W. Betts
2017-06-30 09:35:13 -06:00
committed by Celtic Minstrel
parent 8b727a4ba5
commit 1b210d4358
4 changed files with 15 additions and 6 deletions

View File

@@ -164,6 +164,8 @@ void set_clipboard_img(sf::Image& img) {
NSImage * image = [[NSImage alloc] initWithSize: NSMakeSize(sz.x, sz.y)];
[image addRepresentation: bmp];
NSArray* contents = [NSArray arrayWithObject: image];
[image release];
[bmp release];
NSPasteboard* pb = [NSPasteboard generalPasteboard];
[pb clearContents];
[pb writeObjects: contents];
@@ -178,6 +180,7 @@ std::unique_ptr<sf::Image> get_clipboard_img() {
return ret; // a null pointer
NSImage* img = [[NSImage alloc] initWithPasteboard: pb];
ret.reset(sfImageFromNSImage(img));
[img release];
return ret;
}
@@ -346,6 +349,7 @@ sf::Image* sfImageFromNSImage(NSImage *image) {
sf::Image* sfi = new sf::Image;
sfi->create(width, height, (UInt8*) [rep bitmapData]);
[rep release];
return sfi;
}