NSDrawNinePartImage crash, autorelease sent to freed object
NSDrawNinePartImage crash, autorelease sent to freed object
- Subject: NSDrawNinePartImage crash, autorelease sent to freed object
- From: Richard <email@hidden>
- Date: Sun, 17 Jan 2010 12:02:09 +0000
hey there
i have written a chat client as part of an app i am developing that uses a
subclassed NSTextView to draw bubbles around messages, in the iChat style.
this works well for me and a few hundred other users, except for one who
reports that any time a message is entered the application crashes. the top
of the crash report is below:
OS Version: Mac OS X 10.5.7 (9J61)
Report Version: 6
Anonymous UUID: 0C0AAFBF-22FE-4D33-81D3-A15E1A2D0124
Exception Type: EXC_BAD_INSTRUCTION (SIGILL)
Exception Codes: 0x0000000000000001, 0x0000000000000000
Crashed Thread: 0
Application Specific Information:
objc[79810]: FREED(id): message autorelease sent to freed object=0x15fa3250
Thread 0 Crashed:
0 libobjc.A.dylib 0x9068fbfa _objc_error + 116
1 libobjc.A.dylib 0x9068fc30 __objc_error + 52
2 libobjc.A.dylib 0x9068e637 _freedHandler + 58
3 com.apple.AppKit 0x92cd7c83 _NSTileImageWithOperation +
2061
4 com.apple.AppKit 0x92cf4902 _NSDrawNinePartImage + 1128
5 com.apple.AppKit 0x92f26f2c NSDrawNinePartImage + 575
6 com.bdp.iSoul 0x0002ff61 -[BubbleTextView
drawBubbleAroundTextInRect:user:outgoing:] + 1913
7 com.bdp.iSoul 0x0003097d -[BubbleTextView
drawViewBackgroundInRect:] + 1322
i am not sure how to go about fixing this, can anyone suggest where the
autorelease message is sent? the tiled bubble images are held in NSArrays
and the bubble drawing code in BubbleTextView is shown below. i cannot
understand why the error would occur for this user particularly, can anyone
see something wrong with the code?
- (void)drawBubbleAroundTextInRect:(NSRect)rect user:(User *)user outgoing:(
BOOL)outgoing
{
NSArray *balloon;
NSAffineTransform *aft = [NSAffineTransform transform];
if (outgoing) {
balloon = blueBalloon;
// if outgoing, flip the co-ordinates for the balloon
[aft scaleXBy:-1 yBy:1];
[aft translateXBy:-(2 * rect.origin.x + rect.size.width) yBy:0];
[aft concat];
} else {
...
}
// adjust the paragraph rectangle to contain the balloon
NSRect balloonRect = NSMakeRect(rect.origin.x - kBalloonPadLeft,
rect.origin.y - kBalloonPadTop,
rect.size.width + kBalloonPadLeft + kBalloonPadRight,
rect.size.height + kBalloonPadTop + kBalloonPadBottom);
NSDrawNinePartImage(balloonRect,
[balloon objectAtIndex:0],
[balloon objectAtIndex:1],
[balloon objectAtIndex:2],
[balloon objectAtIndex:3],
[balloon objectAtIndex:4],
[balloon objectAtIndex:5],
[balloon objectAtIndex:6],
[balloon objectAtIndex:7],
[balloon objectAtIndex:8],
NSCompositeSourceOver, 1.0, YES);
[aft invert];
[aft concat];
// now draw the icon, will not be flipped
NSImage *icon;
if ([user icon]) {
icon = [[NSImage alloc] initWithData:[user icon]];
[icon autorelease];
} else {
icon = [NSImage imageNamed:@"PrefAccount"];
}
NSPoint iconOrigin = NSMakePoint(balloonRect.origin.x - kIconBuffer -
kIconSize,
balloonRect.origin.y + balloonRect.size.height);
if (outgoing) iconOrigin.x += kIconSize;
[icon compositeToPoint:iconOrigin operation:NSCompositeSourceOver];
[aft invert];
[aft concat];
// now draw the username
NSRect usernameRect;
NSSize usernameSize = [[user name] sizeWithAttributes:usernameAttributes];
NSRect ourFrame = [self frame];
if (outgoing) {
CGFloat endPoint = ourFrame.origin.x + ourFrame.size.width - kIconBuffer;
CGFloat startPoint = MAX(ourFrame.origin.x + kIconBuffer, endPoint -
usernameSize.width);
usernameRect = NSMakeRect(startPoint, iconOrigin.y, endPoint - startPoint,
kUsernameHeight);
} else {
usernameRect = NSMakeRect(iconOrigin.x, iconOrigin.y,
MIN(usernameSize.width, ourFrame.size.width - kIconBuffer),
kUsernameHeight);
}
[[user name] drawInRect:usernameRect withAttributes:usernameAttributes];
}
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden