[Haiku-commits] r22102 - in haiku/trunk/src/kits: interface tracker

axeld at BerliOS axeld at mail.berlios.de
Wed Aug 29 02:40:42 CEST 2007


Author: axeld
Date: 2007-08-29 02:40:40 +0200 (Wed, 29 Aug 2007)
New Revision: 22102
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=22102&view=rev

Modified:
   haiku/trunk/src/kits/interface/Window.cpp
   haiku/trunk/src/kits/tracker/FindPanel.cpp
Log:
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...


Modified: haiku/trunk/src/kits/interface/Window.cpp
===================================================================
--- haiku/trunk/src/kits/interface/Window.cpp	2007-08-28 21:34:05 UTC (rev 22101)
+++ haiku/trunk/src/kits/interface/Window.cpp	2007-08-29 00:40:40 UTC (rev 22102)
@@ -503,7 +503,8 @@
 BWindow::AddChild(BView *child, BView *before)
 {
 	BAutolock locker(this);
-	fTopView->AddChild(child, before);
+	if (locker.IsLocked())
+		fTopView->AddChild(child, before);
 }
 
 
@@ -511,6 +512,9 @@
 BWindow::RemoveChild(BView *child)
 {
 	BAutolock locker(this);
+	if (!locker.IsLocked())
+		return false;
+
 	return fTopView->RemoveChild(child);
 }
 
@@ -518,7 +522,10 @@
 int32
 BWindow::CountChildren() const
 {
-	BAutolock _(const_cast<BWindow*>(this));
+	BAutolock locker(const_cast<BWindow*>(this));
+	if (!locker.IsLocked())
+		return 0;
+
 	return fTopView->CountChildren();
 }
 
@@ -526,7 +533,10 @@
 BView *
 BWindow::ChildAt(int32 index) const
 {
-	BAutolock _(const_cast<BWindow*>(this));
+	BAutolock locker(const_cast<BWindow*>(this));
+	if (!locker.IsLocked())
+		return NULL;
+
 	return fTopView->ChildAt(index);
 }
 
@@ -1673,7 +1683,10 @@
 BView *
 BWindow::FindView(const char *viewName) const
 {
-	BAutolock _(const_cast<BWindow*>(this));
+	BAutolock locker(const_cast<BWindow*>(this));
+	if (!locker.IsLocked())
+		return NULL;
+
 	return fTopView->FindView(viewName);
 }
 
@@ -1681,7 +1694,10 @@
 BView *
 BWindow::FindView(BPoint point) const
 {
-	BAutolock _(const_cast<BWindow*>(this));
+	BAutolock locker(const_cast<BWindow*>(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 @@
 BWindow::SetLook(window_look look)
 {
 	BAutolock locker(this);
+	if (!locker.IsLocked())
+		return B_BAD_VALUE;
 
 	fLink->StartMessage(AS_SET_LOOK);
 	fLink->Attach<int32>((int32)look);
@@ -1972,6 +1990,8 @@
 BWindow::SetFeel(window_feel feel)
 {
 	BAutolock locker(this);
+	if (!locker.IsLocked())
+		return B_BAD_VALUE;
 
 	fLink->StartMessage(AS_SET_FEEL);
 	fLink->Attach<int32>((int32)feel);
@@ -1995,6 +2015,8 @@
 BWindow::SetFlags(uint32 flags)
 {
 	BAutolock locker(this);
+	if (!locker.IsLocked())
+		return B_BAD_VALUE;
 
 	fLink->StartMessage(AS_SET_FLAGS);
 	fLink->Attach<uint32>(flags);

Modified: haiku/trunk/src/kits/tracker/FindPanel.cpp
===================================================================
--- haiku/trunk/src/kits/tracker/FindPanel.cpp	2007-08-28 21:34:05 UTC (rev 22101)
+++ haiku/trunk/src/kits/tracker/FindPanel.cpp	2007-08-29 00:40:40 UTC (rev 22102)
@@ -78,6 +78,7 @@
 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 @@
 
 //	#pragma mark -
 
-const float kMoreOptionsDelta = 20;
 
 FindPanel::FindPanel(BRect frame, BFile *node, FindWindow *parent,
 	bool , bool editTemplateOnly)
@@ -1830,8 +1830,10 @@
 void
 FindPanel::SetUpAddRemoveButtons(BBox *box)
 {
-	BButton *button = dynamic_cast<BButton *>(Window()->FindView("remove"));
-	if (!button) {	
+	BButton *button = Window() != NULL
+		? dynamic_cast<BButton *>(Window()->FindView("remove"))
+		: NULL;
+	if (button == NULL) {	
 		BRect rect = box->Bounds();
 		rect.InsetBy(5, 10);
 		rect.top = rect.bottom - 20;




More information about the Haiku-commits mailing list