[interfacekit] Re: oddish?

> On Mon, 16 Feb 2004, Adi Oanca wrote:
> 
> > int main()
> > {
> > [...]
> > lay->Invalidate(BRect(225,10,350,400));//BRegion(lay->Bounds()));
> > [...]
> > }
> >

 As Ingo pointed out, this is perfectly valid C++.  I'd like to point out
that this the above is an example of something you should try to avoid.
Not because of the BRect->BRegion thing, but because some compilers
(like ours) have an issue with the scope of temporaries that are used as
arguments.  This only happens sometimes and I'm not really sure under
what circumstances this turns into an error.  (runtime error! :-( )  But it
is safer to do the following:

BRect rect(225,10,350,400);
lay->Invalidate(rect);

And it should be no less efficient.

Andrew
P.S. If I had to guess, I would suspect that one of the circumstances
involves pass-by-reference, which happens here.  But I really have
not pinned down the behavior.


Other related posts: