Problem with: didCompleteLayoutForTextContainer
Problem with: didCompleteLayoutForTextContainer
- Subject: Problem with: didCompleteLayoutForTextContainer
- From: John MacMullin <email@hidden>
- Date: Sat, 23 Apr 2005 14:35:30 -0700
I have a working report in which I have added code to access the text printed on a particular page (not to change it but access it for another purpose). The layoutmanager code follows. The problem line of code is identified below. The error created when I take the comment designations out follow the code.
Is this a bug or am I doing something wrong?
I am using Jaguar 10.2.8.
- (void)layoutManager:(NSLayoutManager *)aLayoutManager didCompleteLayoutForTextContainer:(NSTextContainer *)aTextContainer atEnd:(BOOL)flag
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc]init];
if (!aTextContainer) {
[self buildHeaderStuff];
NSTextContainer *containerFieldOne = [[NSTextContainer alloc]initWithContainerSize:tcFieldOnesize];
NSTextContainer *containerFieldTwo = [[NSTextContainer alloc]initWithContainerSize:tcFieldTwosize];
NSTextContainer *containerFieldThree = [[NSTextContainer alloc]initWithContainerSize:tcFieldThreesize];
NSTextContainer *containerFieldFourNumber = [[NSTextContainer alloc]initWithContainerSize:tcFieldFourNumbersize];
[[[textStorageFieldOne layoutManagers]lastObject]addTextContainer:containerFieldOne];
[[[textStorageFieldTwo layoutManagers]lastObject]addTextContainer:containerFieldTwo];
[[[textStorageFieldThree layoutManagers]lastObject]addTextContainer:containerFieldThree];
[[[textStorageFieldFourNumber layoutManagers]lastObject]addTextContainer:containerFieldFourNumber];
[containerFieldOne release];
[containerFieldTwo release];
[containerFieldThree release];
[containerFieldFourNumber release];
[self developViewSizes];
NSTextView *textViewFieldOne = [[NSTextView alloc] initWithFrame:viewSizeFieldOne textContainer:containerFieldOne];
NSTextView *textViewFieldTwo = [[NSTextView alloc] initWithFrame:viewSizeFieldTwo textContainer:containerFieldTwo];
NSTextView *textViewFieldThree = [[NSTextView alloc] initWithFrame:viewSizeFieldThree textContainer:containerFieldThree];
NSTextView *textViewFieldFourNumber = [[NSTextView alloc] initWithFrame:viewSizeFieldFourNumber textContainer:containerFieldFourNumber];
NSMutableArray *myLayoutManagers = [[NSMutableArray alloc]init];
[myLayoutManagers setArray:[textStorageFieldOne layoutManagers]];
NSMutableArray *myLayoutManagers = [[NSMutableArray alloc]init];
[myLayoutManagers setArray:[textStorageFieldOne layoutManagers]];
//Problem causing error----->//loc = [ [myLayoutManagers lastObject] glyphRangeForTextContainer:[[[myLayoutManagers lastObject] textContainers]lastObject]];
//NSLog(@"%u glyph range location", loc.location);
//NSLog(@"%u glyph range length", loc.length);
NSMutableString *myString = [[NSMutableString alloc]init];
[myString setString:[textStorageFieldOne string]];
NSMutableString *mySubString = [[NSMutableString alloc]init];
//[mySubString setString:[myString substringWithRange:[[myLayoutManagers lastObject]glyphRangeForTextContainer:containerFieldOne]]];
//NSLog(@"%@ substring", mySubString);
[myView addSubview:textViewFieldOne];
[myView addSubview:textViewFieldTwo];
[myView addSubview:textViewFieldThree];
[myView addSubview:textViewFieldFourNumber];
[textViewFieldOne release];
[textViewFieldTwo release];
[textViewFieldThree release];
[textViewFieldFourNumber release];
pointCounter = pointCounter + paperPrintSize.height - headerSize - titleSize - footerSize - (marginSize*2);
[self buildFooterStuff];
[myView setNeedsDisplay:(YES];
[myContainers release];
[myLayoutManagers release];
[myString release];
[mySubString release];
//[myLastLayoutManager release];
}
[pool release];
}
2005-04-23 14:27:13.688 TextPrintingStuff[17090] PMSessionEndDocumentNoDialog failed (error code = -30879)
2005-04-23 14:27:13.689 TextPrintingStuff[17090] *** -[NSAutoreleasePool dealloc]: Exception ignored while releasing an object in an autorelease pool: NSInternalInconsistencyException Failed to end PMPrintContext
_______________________________________________
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