summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Walzer <kw@codebykevin.com>2015-03-10 14:38:20 (GMT)
committerKevin Walzer <kw@codebykevin.com>2015-03-10 14:38:20 (GMT)
commitbc88269ae8c842090cd2d539e0122e820217a9c8 (patch)
tree72533d6a7ace92caf20585245f24a68964a99183
parentb7823b0038de23e91431b6144f6bd6a5dedf0b8a (diff)
downloadtk-bc88269ae8c842090cd2d539e0122e820217a9c8.zip
tk-bc88269ae8c842090cd2d539e0122e820217a9c8.tar.gz
tk-bc88269ae8c842090cd2d539e0122e820217a9c8.tar.bz2
Fix for crash when image is dealloc'ed prematurely in Cocoa
-rw-r--r--macosx/tkMacOSXDraw.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/macosx/tkMacOSXDraw.c b/macosx/tkMacOSXDraw.c
index fa99b14..328f905 100644
--- a/macosx/tkMacOSXDraw.c
+++ b/macosx/tkMacOSXDraw.c
@@ -148,7 +148,8 @@ BitmapRepFromDrawableRect(
cg_image = CGBitmapContextCreateImage( (CGContextRef) cg_context);
sub_cg_image = CGImageCreateWithImageInRect(cg_image, image_rect);
if ( sub_cg_image ) {
- bitmap_rep = [[NSBitmapImageRep alloc] autorelease];
+ /*This can be dealloc'ed prematurely if set for autorelease, causing crashes.*/
+ bitmap_rep = [NSBitmapImageRep alloc];
[bitmap_rep initWithCGImage:sub_cg_image];
}
if ( cg_image ) {
@@ -162,7 +163,8 @@ BitmapRepFromDrawableRect(
width,height);
if ( [view lockFocusIfCanDraw] ) {
- bitmap_rep = [[NSBitmapImageRep alloc] autorelease];
+ /*This can be dealloc'ed prematurely if set for autorelease, causing crashes.*/
+ bitmap_rep = [NSBitmapImageRep alloc];
bitmap_rep = [bitmap_rep initWithFocusedViewRect:view_rect];
[view unlockFocus];
} else {