Re: NSLayoutManager and avoiding widows and orphans
Re: NSLayoutManager and avoiding widows and orphans
- Subject: Re: NSLayoutManager and avoiding widows and orphans
- From: Keith Blount <email@hidden>
- Date: Wed, 7 Nov 2007 15:06:50 -0800 (PST)
Hi Martin,
Thanks for your help (again). Unfortunately, no, this frame adjustment isn't triggered from the delegate methods - I tried to shift everything out of there for the exact reasons you describe. The only thing I do in the delegate method is make note of whether I *need* to adjust the frame. Then I wait for all layout to finish, and only once that's done do I adjust the frame. Then I trigger all layout again, at the end of which I check to see if another adjustment is needed. This goes on until the delegate method doesn't return any more adjustments to be made. But I'm careful not to trigger any extra layout from within the delegate method. The hang happens when the frame change forces the delegate method to add another page. For some reason, this seems to cause everything to go crazy, but I'm not sure why...
Right now I may just have to scrap widow and orphans support from printing in my app altogether. The layout manager just seems too delicate, triggering hangs and crashes that are incredibly difficult to track down.
Thanks again and all the best,
Keith
----- Original Message ----
From: Martin Wierschin <email@hidden>
To: Keith Blount <email@hidden>
Cc: email@hidden
Sent: Wednesday, November 7, 2007 1:24:04 AM
Subject: Re: NSLayoutManager and avoiding widows and orphans
Hi Keith,
So, next I tried waiting until all layout is complete and then enumerating through the text containers, checking for a widow or orphan at the end of each one, adjusting the frame and then forcing layout. But again, if a page gets added because of this, we hit problems - bounds and run storage exceptions, and problems caused by adding a text container whilst enumerating through the text containers.
Do you trigger this frame adjusting from the NSLayoutManager delegate methods? In my experience it is not safe to modify text container geometry/size from this callback. Try this and see if it fixes your crash: after you detect that layout has completed schedule your fixing code via "performSelector:withObject:afterDelay:".
~Martin
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden