From fb82d189d02a686787c6f646143e334b99f6cdaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Fri, 6 Jan 2006 17:14:58 +0000 Subject: [PATCH] * BWindow deletes its view hirachry * BViews set fOwner to NULL recursively when detached * updated a comment git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15851 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/View.cpp | 72 ++++++++++++++++++----------------- src/kits/interface/Window.cpp | 6 +-- 2 files changed, 40 insertions(+), 38 deletions(-) diff --git a/src/kits/interface/View.cpp b/src/kits/interface/View.cpp index 44307ab6f6..8a7d82776a 100644 --- a/src/kits/interface/View.cpp +++ b/src/kits/interface/View.cpp @@ -2287,8 +2287,10 @@ BView::DrawBitmap(const BBitmap *bitmap) void BView::DrawBitmap(const BBitmap *bitmap, BPoint where) { - DrawBitmapAsync(bitmap, where); - Sync(); + if (fOwner) { + DrawBitmapAsync(bitmap, where); + Sync(); + } } @@ -2302,8 +2304,10 @@ BView::DrawBitmap(const BBitmap *bitmap, BRect dstRect) void BView::DrawBitmap(const BBitmap *bitmap, BRect srcRect, BRect dstRect) { - DrawBitmapAsync(bitmap, srcRect, dstRect); - Sync(); + if (fOwner) { + DrawBitmapAsync(bitmap, srcRect, dstRect); + Sync(); + } } @@ -3329,32 +3333,6 @@ BView::RemoveSelf() if (!fParent || !fParent->_RemoveChildFromList(this)) return false; - if (fOwner) { - check_lock(); - - // make sure our owner doesn't need us anymore - - if (fOwner->CurrentFocus() == this) - MakeFocus(false); - - if (fOwner->fDefaultButton == this) - fOwner->SetDefaultButton(NULL); - - if (fOwner->fKeyMenuBar == this) - fOwner->fKeyMenuBar = NULL; - - if (fOwner->fLastMouseMovedView == this) - fOwner->fLastMouseMovedView = NULL; - - if (fOwner->fLastViewToken == _get_object_token_(this)) - fOwner->fLastViewToken = B_NULL_TOKEN; - - BWindow *owner = fOwner; - _SetOwner(NULL); - - owner->fLink->StartMessage(AS_LAYER_DELETE); - } - STRACE(("DONE: BView(%s)::removeSelf()\n", Name())); return true; @@ -4115,9 +4093,33 @@ BView::_Detach() } AllDetached(); -} -#include + if (fOwner) { + check_lock(); + + // make sure our owner doesn't need us anymore + + if (fOwner->CurrentFocus() == this) + MakeFocus(false); + + if (fOwner->fDefaultButton == this) + fOwner->SetDefaultButton(NULL); + + if (fOwner->fKeyMenuBar == this) + fOwner->fKeyMenuBar = NULL; + + if (fOwner->fLastMouseMovedView == this) + fOwner->fLastMouseMovedView = NULL; + + if (fOwner->fLastViewToken == _get_object_token_(this)) + fOwner->fLastViewToken = B_NULL_TOKEN; + + BWindow *owner = fOwner; + _SetOwner(NULL); + + owner->fLink->StartMessage(AS_LAYER_DELETE); + } +} void BView::_Draw(BRect updateRect) @@ -4143,9 +4145,9 @@ BView::_Draw(BRect updateRect) Draw(updateRect); PopState(); } - } else { - // TODO: Find out what happens on R5 if a view has ViewColor() = - // B_TRANSPARENT_COLOR but not B_WILL_DRAW +// } else { + // ViewColor() == B_TRANSPARENT_COLOR and no B_WILL_DRAW + // -> View is simply not drawn at all } for (BView *child = fFirstChild; child != NULL; child = child->fNextSibling) { diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index 8f33dd4392..ecdd31ad40 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -318,6 +318,9 @@ BWindow::~BWindow() delete (Shortcut *)fShortcuts.ItemAt(index); } + fTopView->RemoveSelf(); + delete fTopView; + // TODO: release other dynamically-allocated objects // Deleting this semaphore will tell open menus to quit. @@ -416,9 +419,6 @@ BWindow::Quit() Hide(); } - // ... also its children - //detachTopView(); - if (fFlags & B_QUIT_ON_WINDOW_CLOSE) be_app->PostMessage(B_QUIT_REQUESTED);