AttachedToWindow() could be called twice in case new views were added during

AttachedToWindow().
This fixes the double team entries in the Deskbar.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15398 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-12-07 18:04:43 +00:00
parent ec17c60f5a
commit aa110a00e0
2 changed files with 9 additions and 6 deletions

View File

@ -591,7 +591,7 @@ private:
BScrollBar* fVerScroller;
BScrollBar* fHorScroller;
bool f_is_printing;
bool _unused_bool0;
bool fAttached;
bool _unused_bool1;
bool _unused_bool2;
BPrivate::ViewState* fState;

View File

@ -3274,14 +3274,11 @@ BView::AddChild(BView *child, BView *before)
}
if (!_AddChildToList(child, before))
debugger("AddChild failed - cannot find 'before' view.");
debugger("AddChild failed!");
if (fOwner) {
check_lock();
STRACE(("BView(%s)::AddChild(child='%s' before='%s')... contacting app_server\n",
Name(), child ? child->Name() : "NULL", before ? before->Name() : "NULL"));
child->_SetOwner(fOwner);
child->_CreateSelf();
child->_Attach();
@ -3766,6 +3763,7 @@ BView::_InitData(BRect frame, const char *name, uint32 resizingMode, uint32 flag
fHorScroller = NULL;
f_is_printing = false;
fAttached = false;
fState = new BPrivate::ViewState;
@ -4079,9 +4077,13 @@ void
BView::_Attach()
{
AttachedToWindow();
fAttached = true;
for (BView* child = fFirstChild; child != NULL; child = child->fNextSibling) {
child->_Attach();
// we need to check for fAttachCalled as new views could have been
// added in AttachedToWindow() - and those are already attached
if (!child->fAttached)
child->_Attach();
}
AllAttached();
@ -4092,6 +4094,7 @@ void
BView::_Detach()
{
DetachedFromWindow();
fAttached = false;
for (BView* child = fFirstChild; child != NULL; child = child->fNextSibling) {
child->_Detach();