• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Odd memory issue -- not a newbie
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Odd memory issue -- not a newbie


  • Subject: Re: Odd memory issue -- not a newbie
  • From: "Louis C. Sacha" <email@hidden>
  • Date: Mon, 15 Dec 2003 00:37:17 -0800

Hello...

There should not be a problem adding an additional NSLayoutManager & NSTextContainer(s) to the NSTextStorage, so you should not need to copy or make a new NSTextStorage for things to work properly.

You might have already seen it, but there is some documentation on the relationships between the Text System objects at:

/Developer/Documentation/Cocoa/TasksAndConcepts/ProgrammingTopics/TextArchitecture/index.html

What you are trying to do is very similar to one of the configurations shown under the "Common Configurations" topic (it's just a diagram not sample code, the second from the last one) .

Maybe if you can post the portions of your code that show what you do with the NSTextStorage object, we of the list might be better able to help (since the actual problem is probably lurking somewhere in the code where you build the text architecture for your printing view and then dispose of it... or possibly in Apple's implementation) It's a bit hard to make any specific suggestion without the details.

Louis


I'm printing a text view in a special way, so I use a custom view. Mainly, I'm interested in the text view's text storage, because that's
what I want to print. I tried to write my setter this way:

- (void)setMyStorage:(NSTextStorage *)newStorage
{
[newStorage retain];
[myStorage release];
myStorage = newStorage;
}

When printing is done and my print view is released, it releases
myStorage in dealloc. This all seems pretty standard, and printing
works, but subsequent attempts to edit the text view or use its text
storage result in a crash.

If I do it this way everything works fine:

- (void)setMyStorage:(NSTextStorage *)newStorage
{
[myStorage autorelease];
myStorage = [[NSTextStorage alloc]
initWithAttributedString:newStorage];
}

I'd much rather do it the first way because I don't see the need to
make a copy of what could be a fairly massive attributed string. I'd
rather just retain the text storage, add a new layout manager and text
containers, print my view, then remove my layout manager and release
the text storage. But it doesn't work.

What am I doing wrong?

Jonathan
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Odd memory issue -- not a newbie (From: Jonathan Jackel <email@hidden>)

  • Prev by Date: A little doubt about NSTableView.
  • Next by Date: Re: Providing bindings support
  • Previous by thread: Re: Odd memory issue -- not a newbie
  • Next by thread: Re: Odd memory issue -- not a newbie
  • Index(es):
    • Date
    • Thread