[haiku-development] Re: Hello, and a BBitmap question.

  • From: James Kim <jkim202@xxxxxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Sat, 07 Jun 2008 19:00:53 +1200

Oops, I made a mistake there. It should have been fParent calling
RemoveChild().

Anyway, I tried with your code and it gets in an infinite loop,
printing:

1414141414141414141414141414141414141414141414141414141414141414...

And I am quite sure it's not the problem with BLayout::View() because I
have tested with a test View and it still can only add but not remove.


Regards,

James


On Sat, 2008-06-07 at 01:43 -0500, Rene Gollent wrote:
> On Sat, Jun 7, 2008 at 1:34 AM, James Kim <jkim202@xxxxxxxxxxxxxxxxx> wrote:
> >
> > Thanks, but something else is causing trouble now. I wanted to delete
> > all child views in the parent view and I have just noticed something.
> >
> > Methods such as BView::RemoveSelf(), BView::RemoveChild() does not seem
> > to work on the parent view.
> >
> > For example, I tried counting the number of parent's children after
> > removing each child from the parent view.
> >
> > printf("%d", fParent->CountChildren());
> > for (int32 i = 0; i < fParent->CountChildren(); i++) {
> >        RemoveChild(fParent->ChildAt(i)
> >        printf("%d", fParent->CountChildren());
> > }
> >
> 
> Your loop does have one problem there...you're going to skip more or
> less every other view while doing this. Also, you need to be calling
> RemoveChild off fParent, not off your current view, it can't remove
> what isn't attached to it.
> 
> Try:
> 
> while (fParent->CountChildren() > 0) {
> fParent->RemoveChild(fParent->ChildAt(0));
> printf("%d\n", fParent->CountChildren());
> }
> 
> 
> Regards,
> 
> Rene
> 


Other related posts: