On Jan 13, 2015, at 10:55 PM, Quincey Morris 
<quinceymor...@rivergatesoftware.com> wrote:

> On Jan 13, 2015, at 21:25 , N!K <pu56ucl...@alumni.purdue.edu> wrote:
>> 
>> I have not been able to find  a reason for this behavior. . I don’t know how 
>> to reveal the point between passes where bounds is actually changed. It does 
>> not happen in any other NSView projects of mine; drawRect runs only once in 
>> them
> 
> The immediate reason is probably that the view’s size changed, which is not 
> unlikely when the window is in the process of being displayed. The view may 
> be resized for a “local” reason, such as the application of auto layout 
> constraints, or for a “global” reason, such as the containing being resized 
> and the change filtering down to subviews.
> 
> Another possibility is that the view didn’t change size, but that (as an 
> implementation detail of the Cocoa drawing system) it received two partial 
> invalidations, and these weren’t coalesced in this case.
> 
>> I would like to prevent the second pass, or at least prevent the bounds 
>> change between passes.
> 
> I don’t see any practical way to prevent ‘drawRect’ from being called again.


> Redundant ‘drawRect’ calls can occur any time during the view’s lifetime. 

This I didn’t realize, until you and Jens are explaining to me now. 

> 
> Are you implying that one bounds rect is “right” and one is “wrong”?

No. The system draws the view correctly, as long as I don’t interfere by adding 
my attempt at initialization and scaling.

> If so, how do you know that, and why can’t you just make your code do nothing 
> if the bounds are “wrong”?
> 
> If the only criterion is that the *last* bounds rect is “right”, you’ve got a 
> big problem, because there’s no such concept in the drawing system.
> 
> If you’re hoping that someone can suggest a solution, you probably need to be 
> more specific about what “right” and “wrong” mean. 


> 
>> I’m reluctant to try restoring bounds to its first value. I appreciate Ken 
>> Thomases’ warning in a previous subject not to change bounds in drawRect.
> 
> 
> I’d say it wasn’t a warning, but rather an injunction to never, ever do that. 
> Doing so is Wile E. Coyote stuff.
> 


I wish this had appeared in the Cocoa books I’ve read.


On  a lighter note, the Roadrunner cartoons are my favorites. Every blunder 
presents a classic engineering failure.  :)




_______________________________________________

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to