From be1537b41ae3ec2ddab1e819aa80f02ecabda5d9 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 24 Jan 2016 13:42:11 +0100 Subject: [PATCH] BBox: tolerate non-layouted child in layouted mode While mixing layouted and non-layouted views is not supported, we are doing it in some cases, including translator preferences (which uses layout, but the views may come from a translator add-on which doesn't). So, try to handle that case and at least avoid crashes by calling MinSize/MaxSize and other unsupported layout code on views which won't handle it. Fixes #12610. --- src/kits/interface/Box.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/kits/interface/Box.cpp b/src/kits/interface/Box.cpp index fe0a395b98..0b0cb82054 100644 --- a/src/kits/interface/Box.cpp +++ b/src/kits/interface/Box.cpp @@ -592,14 +592,18 @@ BBox::DoLayout() return; // layout the child - if (BView* child = _Child()) { + BView* child = _Child(); + if (child) { BRect frame(Bounds()); frame.left += fLayoutData->insets.left; frame.top += fLayoutData->insets.top; frame.right -= fLayoutData->insets.right; frame.bottom -= fLayoutData->insets.bottom; - BLayoutUtils::AlignInFrame(child, frame); + if (child->Flags() & B_SUPPORTS_LAYOUT) + BLayoutUtils::AlignInFrame(child, frame); + else + child->MoveTo(frame.LeftTop()); } } @@ -855,7 +859,7 @@ BBox::_ValidateLayoutData() // finally consider the child constraints, if we shall support layout BView* child = _Child(); - if (child && (Flags() & B_SUPPORTS_LAYOUT)) { + if (child && (child->Flags() & B_SUPPORTS_LAYOUT)) { BSize min = child->MinSize(); BSize max = child->MaxSize(); BSize preferred = child->PreferredSize();