hrev45875 adds 2 changesets to branch 'master' old head: ae4da1002b658e020baf665193b5551113583c71 new head: f1eb42958fcb9daf687ca270a94531691f8c0551 overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=f1eb429+%5Eae4da10 ---------------------------------------------------------------------------- 8d75f14: BMenuField: Style fixes f1eb429: BMenuField: Check if Frame() is valid, refactor [ John Scipione <jscipione@xxxxxxxxx> ] ---------------------------------------------------------------------------- 1 file changed, 32 insertions(+), 24 deletions(-) src/kits/interface/MenuField.cpp | 56 ++++++++++++++++++++---------------- ############################################################################ Commit: 8d75f14355c1df1c490ff30524a6894c8c2548da URL: http://cgit.haiku-os.org/haiku/commit/?id=8d75f14 Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu Jul 18 07:21:40 2013 UTC BMenuField: Style fixes ---------------------------------------------------------------------------- diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index f660b9e..d87cdc0 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -788,8 +788,9 @@ BMenuField::PreferredSize() BLayoutItem* BMenuField::CreateLabelLayoutItem() { - if (!fLayoutData->label_layout_item) + if (fLayoutData->label_layout_item == NULL) fLayoutData->label_layout_item = new LabelLayoutItem(this); + return fLayoutData->label_layout_item; } @@ -797,7 +798,7 @@ BMenuField::CreateLabelLayoutItem() BLayoutItem* BMenuField::CreateMenuBarLayoutItem() { - if (!fLayoutData->menu_bar_layout_item) { + if (fLayoutData->menu_bar_layout_item == NULL) { // align the menu bar in the full available space fMenuBar->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH, B_ALIGN_VERTICAL_UNSET)); ############################################################################ Revision: hrev45875 Commit: f1eb42958fcb9daf687ca270a94531691f8c0551 URL: http://cgit.haiku-os.org/haiku/commit/?id=f1eb429 Author: John Scipione <jscipione@xxxxxxxxx> Date: Thu Jul 18 07:22:45 2013 UTC BMenuField: Check if Frame() is valid, refactor ---------------------------------------------------------------------------- diff --git a/src/kits/interface/MenuField.cpp b/src/kits/interface/MenuField.cpp index d87cdc0..83f75eb 100644 --- a/src/kits/interface/MenuField.cpp +++ b/src/kits/interface/MenuField.cpp @@ -916,14 +916,15 @@ BMenuField::DoLayout() // divider float divider = 0; - if (fLayoutData->label_layout_item && fLayoutData->menu_bar_layout_item) { - // We have layout items. They define the divider location. + if (fLayoutData->label_layout_item != NULL + && fLayoutData->menu_bar_layout_item != NULL + && fLayoutData->label_layout_item->Frame().IsValid() + && fLayoutData->menu_bar_layout_item->Frame().IsValid()) { + // We have valid layout items, they define the divider location. divider = fLayoutData->menu_bar_layout_item->Frame().left - fLayoutData->label_layout_item->Frame().left; - } else { - if (fLayoutData->label_width > 0) - divider = fLayoutData->label_width + 5; - } + } else if (fLayoutData->label_width > 0) + divider = fLayoutData->label_width + 5; // menu bar BRect dirty(fMenuBar->Frame()); @@ -1093,25 +1094,31 @@ BMenuField::_UpdateFrame() { CALLED(); - if (fLayoutData->label_layout_item && fLayoutData->menu_bar_layout_item) { - BRect labelFrame = fLayoutData->label_layout_item->Frame(); - BRect menuFrame = fLayoutData->menu_bar_layout_item->Frame(); + if (fLayoutData->label_layout_item == NULL + || fLayoutData->menu_bar_layout_item == NULL) { + return; + } + + BRect labelFrame = fLayoutData->label_layout_item->Frame(); + BRect menuFrame = fLayoutData->menu_bar_layout_item->Frame(); - // update divider - fDivider = menuFrame.left - labelFrame.left; + if (!labelFrame.IsValid() || !menuFrame.IsValid()) + return; - // update our frame - MoveTo(labelFrame.left, labelFrame.top); - BSize oldSize = Bounds().Size(); - ResizeTo(menuFrame.left + menuFrame.Width() - labelFrame.left, - menuFrame.top + menuFrame.Height() - labelFrame.top); - BSize newSize = Bounds().Size(); + // update divider + fDivider = menuFrame.left - labelFrame.left; - // If the size changes, ResizeTo() will trigger a relayout, otherwise - // we need to do that explicitly. - if (newSize != oldSize) - Relayout(); - } + // update our frame + MoveTo(labelFrame.left, labelFrame.top); + BSize oldSize = Bounds().Size(); + ResizeTo(menuFrame.left + menuFrame.Width() - labelFrame.left, + menuFrame.top + menuFrame.Height() - labelFrame.top); + BSize newSize = Bounds().Size(); + + // If the size changes, ResizeTo() will trigger a relayout, otherwise + // we need to do that explicitly. + if (newSize != oldSize) + Relayout(); }