Skip navigation.
 
mlRe: setNeedsDisplayInRect
FROM : Benjohn
DATE : Mon Nov 22 18:33:02 2004

On 30 Jul 2004, at 22:33, <email_removed> wrote:

> Hello,
>
> In my custom view, I make use of (what I thought to be anyway)
> selectively drawing certain content depending on the rectangle passed
> in via NSView's "drawRect:"  method.  However, after some testing, I
> have determined that two calls to "setNeedsDisplayInRect:", when they
> are close by in execution sequence, only the second one goes through.
>
> Expected behavior would have been either to: (Let X be call 1's
> rectangle and Y be call 2's)
>
> 1) Call drawRect:X  and then drawRect:Y
> 2) Z = NSUnionRect(X,Y) and then drawRect:Z
>
> Instead the framework is simply calling drawRect:Y, leaving a lot of
> area in my view unupdated.
>
> So, the questions are -- A) Why does it not choose options 1 or 2
> above? and B) Did I waste my time checking rectangle intersections in
> drawRect to selectively draw portions of my view?
>
> Thanks,
> Rick Bischoff


Did you sort out a satisfactory solution in the end, or come to a
further understanding of the situation?

I seem to be having this problem too. At least: it seems that some of
the calls I make to this method are ignored, while others are not.
There was a reply to this post, but the documentation it helpfully
pointed too didn't enlighten me any further.

In our application, we're sending the "setNeedsDisplayInRect:" calls
from a thread other than the main thread (the main thread being
responsible for actually painting updates in our case). I wondered if
the problem could be due to a race condition between the two threads?
I'm pretty sure I remember reading some Apple documentation indicating
that while parts of the AppKit and Foundation are not thread safe,
"setNeedsDisplayInRect:" is. I don't recall where I read this though :(

Thanks, for any pointers or otherwise
   Benjohn Barnes

Related mailsAuthorDate
No related mails found.