Skip navigation.
 
mlRe: NSLayoutManager and avoiding widows and orphans
FROM : Keith Blount
DATE : Thu Nov 08 00:06:50 2007

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_removed>>
To: Keith Blount <<email_removed>>
Cc: <email_removed>
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

Related mailsAuthorDate
mlNSLayoutManager and avoiding widows and orphans Keith Blount Nov 7, 01:39
mlRe: NSLayoutManager and avoiding widows and orphans Martin Wierschin Nov 7, 02:24
mlRe: NSLayoutManager and avoiding widows and orphans Keith Blount Nov 8, 00:06
mlRe: NSLayoutManager and avoiding widows and orphans Ross Carter Nov 9, 17:32