From b5a9c5218a32730ddc7b47946677fe63a6f33dd8 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Sun, 20 Jan 2013 16:54:23 +0000 Subject: Mac OS: changed memory allocation style of static NSBitmapImageRep* rect_to_NSBitmapImageRep(). git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@9805 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_cocoa.mm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 060fa6e08..23b59b42d 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -3466,7 +3466,7 @@ int Fl::dnd(void) } static NSBitmapImageRep* rect_to_NSBitmapImageRep(Fl_Window *win, int x, int y, int w, int h) -// release the returned value after use +// the returned value is autoreleased { while (win->window()) { x += win->x(); @@ -3479,7 +3479,7 @@ static NSBitmapImageRep* rect_to_NSBitmapImageRep(Fl_Window *win, int x, int y, // left pixel column are not read, and bitmap is read shifted by one pixel in both directions. // Under 10.5, we want no offset. NSRect rect = NSMakeRect(x - epsilon, y - epsilon, w, h); - return [[NSBitmapImageRep alloc] initWithFocusedViewRect:rect]; + return [[[NSBitmapImageRep alloc] initWithFocusedViewRect:rect] autorelease]; } unsigned char *Fl_X::bitmap_from_window_rect(Fl_Window *win, int x, int y, int w, int h, int *bytesPerPixel) @@ -3508,7 +3508,6 @@ unsigned char *Fl_X::bitmap_from_window_rect(Fl_Window *win, int x, int y, int w q += w * *bytesPerPixel; } } - [bitmap release]; return data; } @@ -3521,11 +3520,10 @@ CGImageRef Fl_X::CGImage_from_window_rect(Fl_Window *win, int x, int y, int w, i // CFRelease the returned CGImageRef after use { CGImageRef img; - if (fl_mac_os_version >= 100600) { // crashes with 10.5 + if (fl_mac_os_version >= 100500) { NSBitmapImageRep *bitmap = rect_to_NSBitmapImageRep(win, x, y, w, h); img = (CGImageRef)[bitmap performSelector:@selector(CGImage)]; // requires Mac OS 10.5 CGImageRetain(img); - [bitmap release]; } else { int bpp; -- cgit v1.2.3