From 22ca66b9f86a0e9278ad95099910a2d809b77f07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 29 Aug 2007 00:40:40 +0000 Subject: [PATCH] Fixed bug #1028 from both sides: * FindPanel::SetUpAddRemoveButtons() called Window()->FindView() but did not check if Window() was NULL. * BWindow now always checks the result of a BAutolock - this is why Tracker got away with this bug on BeOS; NULL windows cannot be locked... git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22102 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Window.cpp | 32 +++++++++++++++++++++++++++----- src/kits/tracker/FindPanel.cpp | 8 +++++--- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/kits/interface/Window.cpp b/src/kits/interface/Window.cpp index a89906aceb..d41974e88b 100644 --- a/src/kits/interface/Window.cpp +++ b/src/kits/interface/Window.cpp @@ -503,7 +503,8 @@ void BWindow::AddChild(BView *child, BView *before) { BAutolock locker(this); - fTopView->AddChild(child, before); + if (locker.IsLocked()) + fTopView->AddChild(child, before); } @@ -511,6 +512,9 @@ bool BWindow::RemoveChild(BView *child) { BAutolock locker(this); + if (!locker.IsLocked()) + return false; + return fTopView->RemoveChild(child); } @@ -518,7 +522,10 @@ BWindow::RemoveChild(BView *child) int32 BWindow::CountChildren() const { - BAutolock _(const_cast(this)); + BAutolock locker(const_cast(this)); + if (!locker.IsLocked()) + return 0; + return fTopView->CountChildren(); } @@ -526,7 +533,10 @@ BWindow::CountChildren() const BView * BWindow::ChildAt(int32 index) const { - BAutolock _(const_cast(this)); + BAutolock locker(const_cast(this)); + if (!locker.IsLocked()) + return NULL; + return fTopView->ChildAt(index); } @@ -1673,7 +1683,10 @@ BWindow::UpdateIfNeeded() BView * BWindow::FindView(const char *viewName) const { - BAutolock _(const_cast(this)); + BAutolock locker(const_cast(this)); + if (!locker.IsLocked()) + return NULL; + return fTopView->FindView(viewName); } @@ -1681,7 +1694,10 @@ BWindow::FindView(const char *viewName) const BView * BWindow::FindView(BPoint point) const { - BAutolock _(const_cast(this)); + BAutolock locker(const_cast(this)); + if (!locker.IsLocked()) + return NULL; + // point is assumed to be in window coordinates, // fTopView has same bounds as window return _FindView(fTopView, point); @@ -1946,6 +1962,8 @@ status_t BWindow::SetLook(window_look look) { BAutolock locker(this); + if (!locker.IsLocked()) + return B_BAD_VALUE; fLink->StartMessage(AS_SET_LOOK); fLink->Attach((int32)look); @@ -1972,6 +1990,8 @@ status_t BWindow::SetFeel(window_feel feel) { BAutolock locker(this); + if (!locker.IsLocked()) + return B_BAD_VALUE; fLink->StartMessage(AS_SET_FEEL); fLink->Attach((int32)feel); @@ -1995,6 +2015,8 @@ status_t BWindow::SetFlags(uint32 flags) { BAutolock locker(this); + if (!locker.IsLocked()) + return B_BAD_VALUE; fLink->StartMessage(AS_SET_FLAGS); fLink->Attach(flags); diff --git a/src/kits/tracker/FindPanel.cpp b/src/kits/tracker/FindPanel.cpp index 10ad81fd6f..5c85c5ade3 100644 --- a/src/kits/tracker/FindPanel.cpp +++ b/src/kits/tracker/FindPanel.cpp @@ -78,6 +78,7 @@ const char *kAllMimeTypes = "mime/ALLTYPES"; const BRect kInitialRect(100, 100, 530, 210); const int32 kInitialAttrModeWindowHeight = 140; const int32 kIncrementPerAttribute = 30; +const float kMoreOptionsDelta = 20; const uint32 kMoreOptionsMessage = 'mrop'; const uint32 kNameModifiedMessage = 'nmmd'; @@ -639,7 +640,6 @@ FindWindow::MessageReceived(BMessage *message) // #pragma mark - -const float kMoreOptionsDelta = 20; FindPanel::FindPanel(BRect frame, BFile *node, FindWindow *parent, bool , bool editTemplateOnly) @@ -1830,8 +1830,10 @@ FindPanel::AddOneAttributeItem(BBox *box, BRect rect) void FindPanel::SetUpAddRemoveButtons(BBox *box) { - BButton *button = dynamic_cast(Window()->FindView("remove")); - if (!button) { + BButton *button = Window() != NULL + ? dynamic_cast(Window()->FindView("remove")) + : NULL; + if (button == NULL) { BRect rect = box->Bounds(); rect.InsetBy(5, 10); rect.top = rect.bottom - 20;