From 93977272f4854e506ecfa0e007eae791415418d0 Mon Sep 17 00:00:00 2001 From: Alex Wilson Date: Thu, 19 Jan 2012 13:36:47 +1300 Subject: [PATCH] When adding tabs to a BALMLayout, ensure they are fully added. --- src/libs/alm/ALMLayout.cpp | 46 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/src/libs/alm/ALMLayout.cpp b/src/libs/alm/ALMLayout.cpp index 25811ef86d..b679690aaa 100644 --- a/src/libs/alm/ALMLayout.cpp +++ b/src/libs/alm/ALMLayout.cpp @@ -26,13 +26,21 @@ const BSize kUnsetSize(B_SIZE_UNSET, B_SIZE_UNSET); struct BALMLayout::XTabRemoverFunc { + XTabRemoverFunc() + { + } + void operator()(XTab* tab) { - if (tab) + if (tab) { layout->_RemoveSelfFromTab(tab); + if (index > 0) + layout->fXTabList.RemoveItemAt(index); + } } BALMLayout* layout; + int32 index; }; @@ -47,17 +55,30 @@ struct BALMLayout::XTabRemover { fDelete.layout = layout; } + + void SetIndexTo(int32 index) + { + fDelete.index = index; + } }; struct BALMLayout::YTabRemoverFunc { + YTabRemoverFunc() + { + } + void operator()(YTab* tab) { - if (tab) + if (tab) { layout->_RemoveSelfFromTab(tab); + if (index > 0) + layout->fYTabList.RemoveItemAt(index); + } } BALMLayout* layout; + int32 index; }; @@ -72,6 +93,11 @@ struct BALMLayout::YTabRemover { fDelete.layout = layout; } + + void SetIndexTo(int32 index) + { + fDelete.index = index; + } }; @@ -558,6 +584,10 @@ BALMLayout::AddItem(BLayoutItem* item, XTab* left, YTab* top, XTab* _right, if (!left->AddedToLayout(this)) return NULL; leftRemover.SetTo(left); + + if (!fXTabList.AddItem(left, fXTabList.CountItems())) + return NULL; + leftRemover.SetIndexTo(fXTabList.CountItems() - 1); } YTabRemover topRemover(this); @@ -565,6 +595,10 @@ BALMLayout::AddItem(BLayoutItem* item, XTab* left, YTab* top, XTab* _right, if (!top->AddedToLayout(this)) return NULL; topRemover.SetTo(top); + + if (!fYTabList.AddItem(top, fYTabList.CountItems())) + return NULL; + topRemover.SetIndexTo(fYTabList.CountItems() - 1); } XTabRemover rightRemover(this); @@ -572,6 +606,10 @@ BALMLayout::AddItem(BLayoutItem* item, XTab* left, YTab* top, XTab* _right, if (!right->AddedToLayout(this)) return NULL; rightRemover.SetTo(right); + + if (!fXTabList.AddItem(right, fXTabList.CountItems())) + return NULL; + rightRemover.SetIndexTo(fXTabList.CountItems() - 1); } YTabRemover bottomRemover(this); @@ -579,6 +617,10 @@ BALMLayout::AddItem(BLayoutItem* item, XTab* left, YTab* top, XTab* _right, if (!bottom->AddedToLayout(this)) return NULL; bottomRemover.SetTo(bottom); + + if (!fYTabList.AddItem(bottom, fYTabList.CountItems())) + return NULL; + bottomRemover.SetIndexTo(fYTabList.CountItems() - 1); } // Area is added in ItemAdded