Re(2): God, that's NOT THE WAY!!!! (was: Use -display INSTEAD of -setNeedsDisplay)
Re(2): God, that's NOT THE WAY!!!! (was: Use -display INSTEAD of -setNeedsDisplay)
- Subject: Re(2): God, that's NOT THE WAY!!!! (was: Use -display INSTEAD of -setNeedsDisplay)
- From: Jens Bauer <email@hidden>
- Date: Wed, 19 Dec 2001 13:19:57 +0100
Hi,
If anybody from Apple by accident reads this mail.. ;)
Please make sure that the needsDisplay flag is cleared by
the forceDisplay method and not the display method:
- (void)setNeedsDisplay:(BOOL) inNeedsDisplay
{
needsDisplay = inNeedsDisplay;
}
- (void)display
{
if(needsDisplay)
{
// needsDisplay = NO; // Not in here!
[self forceDisplay];
}
}
- (void)forceDisplay
{
needsDisplay = NO; // but in here!
.. display the object
}
If you use the above way, you may save a redraw now and then.
When looking at the code (that is commented out), it doesn't look
wrong at first sight. Clearing the flag in the correct part may
save us from unnecessary drawing.
(Please forgive me from being so obvious; I just want to make sure that
the above mistake is not implemented.)
In fact you probably need to add an additional mistake for the above to
be slowed down; a call to forceDisplay followed by a call to display.
On Mon, 17 Dec, 2001, Erik M. Buck <email@hidden> wrote:
>
The terrible performance resulting from use of -setNeedsDisplay: has been
>
reported.
>
>
Your bug report has been accepted and assigned Problem ID# :2830615.
>
>
----- Original Message -----
>
From: "John C. Randolph" <email@hidden>
>
To: <email@hidden>
>
Sent: Monday, December 17, 2001 8:32 AM
>
Subject: Re: God, that's NOT THE WAY!!!! (was: Use -display INSTEAD
>
of -setNeedsDisplay)
>
>
>
> On Monday, December 17, 2001, at 05:49 AM, Ondra Cada wrote:
>
>
>
> > Erik,
>
> >
>
> >>>>>>> Erik M. Buck (EMB) wrote at Sun, 16 Dec 2001 21:24:46 -0600:
>
> > ...
>
> > EMB> I hereby reverse my previous very insistent assertion that
>
> > EMB> -setNeedsDisplay: should be used in preference to -display
>
> > whenever
>
> > EMB> possible. The opposite is actually true.
>
> > EMB>
>
> > EMB> Use -display rather than -setNeedsDisplay: whenever possible.
>
> > ...
>
> >
>
> > That would seriously broke efficiency of all applications for
>
> > years to come.
>
> > Just please *ANYBODY* who has *ANY* influence in Apple, roar to
>
> > them to FIX
>
> > THIS VERY SERIOUS BUG ASAP!
I'm sure that calling display multiple times won't do a thing.
It should definately just check the needsDisplay flag (as mentioned above),
and forget about it if the answer is 'NO'.
Currently I can't test it, but *you* can, if you run the following code:
[myButton setTitle:@"not refreshed"]; // "initial text"
[myButton display]; // make sure we see it
[myButton setTitle:@"refreshed, error!"]; // change the text (sets
needsDisplay)
[myButton setNeedsDisplay:NO]; // lie to the display method
[myButton display]; // display the button if
needsDisplay is set
-Am I right ?
(It could be that Apple keeps another flag that the button has changed.
If this is the case,
the above example will prove nothing.)
Love,
Jens