Update CollapsingLayouter to fix crashes in a few applications. All these crashes were related to empty layouts. Fixes some of #7446

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@41256 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Alex Wilson
2011-04-15 18:35:26 +00:00
parent 4d9ffa5ff9
commit 5e5a8daf68
@@ -195,7 +195,7 @@ float
CollapsingLayouter::MinSize() CollapsingLayouter::MinSize()
{ {
_ValidateLayouter(); _ValidateLayouter();
return fLayouter->MinSize(); return fLayouter ? fLayouter->MinSize() : 0;
} }
@@ -203,7 +203,7 @@ float
CollapsingLayouter::MaxSize() CollapsingLayouter::MaxSize()
{ {
_ValidateLayouter(); _ValidateLayouter();
return fLayouter->MaxSize(); return fLayouter ? fLayouter->MaxSize() : B_SIZE_UNLIMITED;
} }
@@ -211,7 +211,7 @@ float
CollapsingLayouter::PreferredSize() CollapsingLayouter::PreferredSize()
{ {
_ValidateLayouter(); _ValidateLayouter();
return fLayouter->PreferredSize(); return fLayouter ? fLayouter->PreferredSize() : 0;
} }
@@ -220,7 +220,8 @@ CollapsingLayouter::CreateLayoutInfo()
{ {
_ValidateLayouter(); _ValidateLayouter();
return new ProxyLayoutInfo(fLayouter->CreateLayoutInfo(), fElementCount); LayoutInfo* info = fLayouter ? fLayouter->CreateLayoutInfo() : NULL;
return new ProxyLayoutInfo(info, fElementCount);
} }
@@ -328,6 +329,9 @@ CollapsingLayouter::_AddConstraints(int32 position, const Constraint* c)
void void
CollapsingLayouter::_SetWeights() CollapsingLayouter::_SetWeights()
{ {
if (!fLayouter)
return;
for (int32 i = 0; i < fElementCount; i++) { for (int32 i = 0; i < fElementCount; i++) {
fLayouter->SetWeight(fElements[i].position, fElements[i].weight); fLayouter->SetWeight(fElements[i].position, fElements[i].weight);
} }