Crash in -[NSString(NSStringDrawing) drawInRect:withAttributes:] on 10.3.9
Crash in -[NSString(NSStringDrawing) drawInRect:withAttributes:] on 10.3.9
- Subject: Crash in -[NSString(NSStringDrawing) drawInRect:withAttributes:] on 10.3.9
- From: "Shawn Erickson" <email@hidden>
- Date: Tue, 22 Aug 2006 09:01:53 -0700
Didn't hit anything when I searched but I am wondering if anyone else
has seen a periodic crash down in -[NSString(NSStringDrawing)
drawInRect:withAttributes:] when running on 10.3.9 (doesn't happen on
10.4 and we only support 10.3.9 and later with our products).
The crash doesn't happen very often but when it does it always happens
in the fashion outlined in the backtrace below (in one of the two uses
of drawInRect:withAttributes: in my code). Reviewing code outside of
the below we see no way for any incorrect state for rightText,
leftText, or font (all ivars with related setters, we copy the strings
and textArea is a constant), also walked thru it many times in the
debugger.
Anyway seen something similar and have a suggestion on a work around
(I guess I could try switching to building NSAttributedStrings in my
setters and draw those). Note this code isn't in a hot pathway
(doesn't get hit unless that exact area needs updating, often only
gets hit once on initial display).
- (void)drawRect:(NSRect)rect {
...
if (font != nil) {
NSRect textArea = NSInsetRect([self bounds], barInset + 1,
barInset + 1);
NSMutableParagraphStyle* paragraphStyle =
[[[NSMutableParagraphStyle alloc] init] autorelease];
[paragraphStyle setLineBreakMode:NSLineBreakByTruncatingTail];
if (leftText != nil) {
[paragraphStyle setAlignment:NSLeftTextAlignment];
NSDictionary* atts = [NSDictionary dictionaryWithObjectsAndKeys:
font, NSFontAttributeName,
paragraphStyle, NSParagraphStyleAttributeName,
nil];
[leftText drawInRect:textArea withAttributes:atts]; << here
}
if (rightText != nil) {
[paragraphStyle setAlignment:NSRightTextAlignment];
NSDictionary* atts = [NSDictionary dictionaryWithObjectsAndKeys:
font, NSFontAttributeName,
paragraphStyle, NSParagraphStyleAttributeName,
nil];
[rightText drawInRect:textArea withAttributes:atts]; << or here
}
}
...
}
Thread 0 Crashed:
0 libobjc.A.dylib 0x908611ec objc_msgSend + 0xc
1 com.apple.Foundation 0x90a69900 -[NSDictionary
isEqualToDictionary:] + 0x44
2 com.apple.AppKit 0x92e95e7c attributeDictionaryIsEqual + 0xa4
3 com.apple.CoreFoundation 0x901c6500 __CFSetFindBuckets1 + 0xd8
4 com.apple.CoreFoundation 0x901cd8f0 CFSetGetValue + 0xc8
5 com.apple.AppKit 0x92ea4f38 +[NSAttributeDictionary
newWithDictionary:] + 0xc4
6 com.apple.Foundation 0x90a311fc
-[NSConcreteAttributedString initWithString:attributes:] + 0x7c
7 com.apple.AppKit 0x92f06dc4
-[NSString(NSStringDrawing) drawInRect:withAttributes:] + 0x108
8 com.blah 0x00044efc -[blah drawRect:] - blah.m:273
...
9 com.apple.AppKit 0x92e77094 -[NSView _drawRect:clip:] + 0x770
10 com.apple.AppKit 0x92e87ad8 -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 0xe8
11 com.apple.AppKit 0x92ebd84c _recursiveDisplayInRect2 + 0x54
12 com.apple.CoreFoundation 0x901cf074 CFArrayApplyFunction + 0x198
13 com.apple.AppKit 0x92e87bdc -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 0x1ec
14 com.apple.AppKit 0x92ebd84c _recursiveDisplayInRect2 + 0x54
15 com.apple.CoreFoundation 0x901cf074 CFArrayApplyFunction + 0x198
16 com.apple.AppKit 0x92e87bdc -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 0x1ec
17 com.apple.AppKit 0x92ebd84c _recursiveDisplayInRect2 + 0x54
18 com.apple.CoreFoundation 0x901cf074 CFArrayApplyFunction + 0x198
19 com.apple.AppKit 0x92e87bdc -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 0x1ec
20 com.apple.AppKit 0x92ebd84c _recursiveDisplayInRect2 + 0x54
21 com.apple.CoreFoundation 0x901cf074 CFArrayApplyFunction + 0x198
22 com.apple.AppKit 0x92e87bdc -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 0x1ec
23 com.apple.AppKit 0x92ebd84c _recursiveDisplayInRect2 + 0x54
24 com.apple.CoreFoundation 0x901cf074 CFArrayApplyFunction + 0x198
25 com.apple.AppKit 0x92e87bdc -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 0x1ec
26 com.apple.AppKit 0x92ebd84c _recursiveDisplayInRect2 + 0x54
27 com.apple.CoreFoundation 0x901cf074 CFArrayApplyFunction + 0x198
28 com.apple.AppKit 0x92e87bdc -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:] + 0x1ec
29 com.apple.AppKit 0x92ec02d8 -[NSFrameView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
+ 0x90
30 com.apple.AppKit 0x92ea74f0 -[NSThemeFrame
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
+ 0xc0
31 com.apple.AppKit 0x92e846ac -[NSView
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:] +
0x180
32 com.apple.AppKit 0x92e9d6d8 -[NSView displayIfNeeded] + 0xa8
33 com.apple.AppKit 0x92eae3c8 -[NSWindow
displayIfNeeded] + 0xb4
34 com.apple.AppKit 0x92ed24ec -[NSWindow
_reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:] +
0x3a8
35 com.apple.AppKit 0x92f7ab94 -[NSWindow
makeKeyAndOrderFront:] + 0xa0
...
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden