Hi Ross, Thank you for your reply and pointers. (Sorry it took so long; I didn't see your reply until today).
>On Sep 7, 2010, at 12:22 PM, Jens Bauer wrote: > >> ...Does anyone have an idea about why the number of layout managers >> increase ? > >I don't know the answer, but I expect it is easy to find out. Set a >breakpoint on layout manager -init and see who is creating them. Or, >look at the contents of the layout managers array and see what it tells you. As I don't know how to set breakpoint in NSLayoutManager's -init with Xcode 2.5, I picked the second option. Looking and comparing the layout managers in the array, I found out only one was unique; the first (n-1) layout managers all had the same information (compared using cmd-e and cmd-g in the log window. - For instance, I get 15 of these (after switching back and forth 15 times): <NSLayoutManager: 0x29a7a0>, <NSLayoutManager: 0x7901fe0>, <NSLayoutManager: 0x7904f90>, <NSLayoutManager: 0x7908a20>, <NSLayoutManager: 0x790a460>, <NSLayoutManager: 0x2fbcf0>, <NSLayoutManager: 0x7913d30>, <NSLayoutManager: 0x79084b0>, <NSLayoutManager: 0x7910d60>, <NSLayoutManager: 0x7913a40>, <NSLayoutManager: 0x7922710>, <NSLayoutManager: 0x7922b80>, <NSLayoutManager: 0x7929df0>, <NSLayoutManager: 0x792b730>, <NSLayoutManager: 0x792dac0> ...all containing the following: 1 containers, text backing has 2952 characters selected character range {0, 0} affinity: downstream granularity: character marked character range {2952, 0} Currently holding 2952 glyphs. Glyph tree contents: 2952 characters, 2952 glyphs, 1 nodes, 32 node bytes, 4096 storage bytes, 4128 total bytes, 1.40 bytes per character, 1.40 bytes per glyph Layout tree contents: 2952 characters, 2952 glyphs, 2952 laid glyphs, 106 laid line fragments, 1 nodes, 32 node bytes, 10200 storage bytes, 10232 total bytes, 3.47 bytes per character, 3.47 bytes per glyph, 27.85 laid glyphs per laid line fragment, 96.53 bytes per laid line fragment and one of these, which is the last one in the array: <NSLayoutManager: 0x7934990> 1 containers, text backing has 2952 characters selected character range {0, 0} affinity: upstream granularity: character marked character range {2952, 0} Currently holding 2952 glyphs. Glyph tree contents: 2952 characters, 2952 glyphs, 1 nodes, 32 node bytes, 0 storage bytes, 32 total bytes, 0.01 bytes per character, 0.01 bytes per glyph Layout tree contents: 2952 characters, 2952 glyphs, 0 laid glyphs, 0 laid line fragments, 1 nodes, 32 node bytes, 0 storage bytes, 32 total bytes, 0.01 bytes per character, 0.01 bytes per glyph, 0.00 laid glyphs per laid line fragment, 0.00 bytes per laid line fragment I do not know much about the inner workings of the layout manager, but I can see that the "Glyph storage bytes" is zero (as well as laid glyphs) in the last layout manager, where it's 4096 in all the others); the storage bytes for the Layout tree is also zero in the last layout manager, where it's 10200 bytes in the others. -This is probably because the new layout manager didn't do any "work" yet. When doing something I probably should not do, it fixes the # of layout managers problem... [layoutManager replaceTextStorage:fileContents]; // This seems to fix the crash, but keeps creating more layoutManagers! // keep only the last added layout manager: while([[[textView textStorage] layoutManagers] count] > 1) { [[textView textStorage] removeLayoutManager:[[[textView textStorage] layoutManagers] objectAtIndex:0]]; } I'm pretty convinced I'm not supposed to do things like that. If removing all the layout managers before I do a replaceTextStorage, I get a crash. :) The extra layout managers are probably present because there's something I did not clean up; maybe I've overlooked something in the docs, or I need to use a different approach for having a file list that is switched in/out of a single NSTextView. Love, Jens _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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 arch...@mail-archive.com