Hi all,

I'm getting a crash report from one user who has experienced the following crash more than once. No other user is reporting this so far. The crash is down in the text editing engine and I'm not sure what I should be looking at in my usage of this code that could be causing it. Suggestions welcome.

My first instinct is that the text view has been released and that I'm messaging a stale pointer, but if that's the case I can't see how the code could have made it as far as it has. Besides, the text view is retained by another object for as long as it lives - it's only released in -dealloc. I've checked that there are no other releases or autoreleases on it.

0   libobjc.A.dylib                     0x9561991b objc_msgSend + 27
1 libobjc.A.dylib 0x956213b2 prepareForMethodLookup + 85
2   libobjc.A.dylib                     0x95622657 lookUpMethod + 86
3 libobjc.A.dylib 0x95619da7 _class_lookupMethodAndLoadCache + 40
4   libobjc.A.dylib                     0x95619953 objc_msgSend + 83
5 com.apple.AppKit 0x94b6f2e1 -[NSTextView(NSSharing) setSelectedRange:] + 64 6 com.apple.AppKit 0x94b6bd62 -[NSLayoutManager textStorage:edited:range:changeInLength:invalidatedRange:] + 445 7 com.apple.AppKit 0x94b38100 -[NSTextStorage _notifyEdited:range:changeInLength:invalidatedRange:] + 132 8 com.apple.AppKit 0x94b37921 -[NSTextStorage processEditing] + 218 9 com.apple.AppKit 0x94b3781e -[NSTextStorage edited:range:changeInLength:] + 272 10 com.apple.Foundation 0x95d8063c - [NSConcreteMutableAttributedString replaceCharactersInRange:withAttributedString:] + 413 11 com.apple.AppKit 0x94bd14c7 -[NSConcreteTextStorage replaceCharactersInRange:withAttributedString:] + 102


0   libobjc.A.dylib                     0x9561992c objc_msgSend + 44
1 com.apple.AppKit 0x94b6f2e1 -[NSTextView(NSSharing) setSelectedRange:] + 64 2 com.apple.AppKit 0x94b6bd62 -[NSLayoutManager textStorage:edited:range:changeInLength:invalidatedRange:] + 445 3 com.apple.AppKit 0x94b38100 -[NSTextStorage _notifyEdited:range:changeInLength:invalidatedRange:] + 132 4 com.apple.AppKit 0x94b37921 -[NSTextStorage processEditing] + 218 5 com.apple.AppKit 0x94b3781e -[NSTextStorage edited:range:changeInLength:] + 272 6 com.apple.Foundation 0x95d8063c - [NSConcreteMutableAttributedString replaceCharactersInRange:withAttributedString:] + 413 7 com.apple.AppKit 0x94bd14c7 -[NSConcreteTextStorage replaceCharactersInRange:withAttributedString:] + 102

The code here looks like this:

- (NSTextView*) editText:(NSTextStorage*) text inRect:(NSRect) rect delegate:(id) del drawsBackground:(BOOL) drawBkGnd
{
NSAssert( text != nil, @"text was nil when trying to start a text editing operation");
        NSAssert( rect.size.width > 0, @"editing rect has 0 or -ve width");
        NSAssert( rect.size.height > 0, @"editing rect has 0 or -ve height");

        if ([self isTextBeingEdited])
                [self endTextEditing];
        
// editor's frame is expanded by five points to ensure all characters are visible when not using screen fonts
        // container text inset is later set to compensate for this.

        NSRect editorFrame = NSInsetRect( rect, -5, -5 );
        
        if( m_textEditViewRef == nil )
m_textEditViewRef = [[[[self class] classForTextEditor] alloc] initWithFrame:editorFrame];
        else
                [m_textEditViewRef setFrame:editorFrame];
        
        [m_textEditViewRef setAllowsUndo:NO];
        
NSRange textRange = NSMakeRange( 0, [[m_textEditViewRef textStorage] length]); [[m_textEditViewRef textStorage] replaceCharactersInRange:textRange withAttributedString:text];

_______________________________________________

Cocoa-dev mailing list ([email protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to