Strange text system problem, seems like a bug
Strange text system problem, seems like a bug
- Subject: Strange text system problem, seems like a bug
- From: Ondra Cada <email@hidden>
- Date: Thu, 13 Apr 2006 03:59:37 +0200
Hello all, namely Douglas Davidson,
I've bumped into a weird behaviour... my application draws some text
through layout manager (that is all right and works without any
problem at all), and also sets the very same attributes to an
NSTextView. That, though, seems to cause problem: seems that with
some attributes, NSATSTypesetter uses bad index?!? The error is
pretty often, but happens with some attributes only -- I haven't been
able to find with which ones exactly, seems kind of stochastic :(
Here is my code:
NSDictionary *d=[self textStyle];
if (d && textView) {
NSTextStorage *tts=[textView textStorage];
@try {
NSLog(@"=== setting attributes: %@\n=== for text
storage: %@",d,tts);
[tts setAttributes:d range:NSMakeRange(0,[tts length])];
NSLog(@"=== done");
} @catch (id o) {
NSLog(@"exception %@",o);
}
}
Here is the result (including the backtrack at the moment of the
exception):
2006-04-13 03:49:36.772 GrendBlockTest[24954] === setting attributes: {
NSColor = NSCalibratedRGBColorSpace 0.408822 0.669683 0.0214197 1;
NSFont = "HoeflerText-BlackItalic 24.00 pt. P [] (0x033353b0)
fobj=0x030c7730, spc=4.92";
NSKern = -1.1;
NSParagraphStyle = Alignment 3, LineSpacing 0, ParagraphSpacing
0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0,
FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0,
LineBreakMode 0, Tabs (28L, 56L, 84L, 112L, 140L, 168L, 196L, 224L,
252L, 280L, 308L, 336L), DefaultTabInterval 0, Blocks (null), Lists
(null), BaseWritingDirection -1, HyphenationFactor 0,
TighteningFactor 0.05, HeaderLevel 0;
NSShadow = NSShadow {1.48841, -11.9073} blur = 6.2069 color =
{NSCalibratedRGBColorSpace 0 0 0 1};
NSUnderline = 1;
}
=== for text storage: Text sample: this text is freely editable, and
has nothing to do with the displayed data. It is just a style sample{
NSColor = NSNamedColorSpace System textColor;
NSFont = "Helvetica 12.00 pt. P [] (0x030cf2f0) fobj=0x0035aa40,
spc=3.33";
}
2006-04-13 03:49:36.773 GrendBlockTest[24954] === done
2006-04-13 03:49:36.849 GrendBlockTest[24954] -[NSTextStorage
attribute:atIndex:longestEffectiveRange:inRange:] called with out-of-
bounds index. For apps linked on Tiger this will raise an exception.
For earlier apps it will produce this one-time warning and continue
with existing behavior (which is undefined).
(gdb) bt
#0 0x92902228 in -[NSException raise] ()
#1 0x9290207c in +[NSException raise:format:] ()
#2 0x93765044 in -[NSConcreteTextStorage
attribute:atIndex:longestEffectiveRange:inRange:] ()
#3 0x9370feb8 in -[NSTypesetter beginParagraph] ()
#4 0x9370fd88 in -[NSATSTypesetter beginParagraph] ()
#5 0x9370fa08 in -[NSATSTypesetter layoutParagraphAtPoint:] ()
#6 0x936fc4cc in -[NSTypesetter
layoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragment
s:nextGlyphIndex:] ()
#7 0x936fb9f0 in -[NSATSTypesetter
layoutGlyphsInLayoutManager:startingAtGlyphIndex:maxNumberOfLineFragment
s:nextGlyphIndex:] ()
#8 0x9370d57c in -[NSLayoutManager(NSPrivate)
_fillLayoutHoleAtIndex:desiredNumberOfLines:] ()
#9 0x9375fa94 in +[NSLayoutManager(NSPrivate)
_doSomeBackgroundLayout] ()
#10 0x9375f6e4 in _NSPostBackgroundLayout ()
#11 0x9075ccd8 in __CFRunLoopDoObservers ()
#12 0x9075cf78 in __CFRunLoopRun ()
#13 0x9075ca18 in CFRunLoopRunSpecific ()
#14 0x9318f1e0 in RunCurrentEventLoopInMode ()
#15 0x9318e7ec in ReceiveNextEventCommon ()
#16 0x9318e6e0 in BlockUntilNextEventMatchingListInMode ()
#17 0x9368d104 in _DPSNextEvent ()
#18 0x9368cdc8 in -[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:] ()
#19 0x9368930c in -[NSApplication run] ()
#20 0x93779e68 in NSApplicationMain ()
#21 0x00290fac in main (argc=1, argv=0xbffffa30) at /Volumes/300/
Projects/Sedin/Grend/GrendBlockTest/main.m:13
(gdb) c
2006-04-13 03:57:11.273 GrendBlockTest[24954] <NSATSTypesetter:
0x35da70>: Exception *** -[NSConcreteTextStorage
attribute:atIndex:longestEffectiveRange:inRange:]: Range or index out
of bounds raised during typesetting layout manager <NSLayoutManager:
0x30bb450>
1 containers, text backing has 115 characters
selected character range {0, 0} affinty: upstream granularity:
character
marked character range {115, 0}
Currently holding 116 glyphs with 0 glyph holes and 1 layout holes.
Glyph holes: ()
Layout holes: (Hard layout hole for chars: {0, 115})
, glyph range {115 1}. Ignoring...
Continuing.
---
Ondra Čada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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