hrev43570 adds 3 changesets to branch 'master' old head: 2cb6157746298d19939dfa2ff8a6f472a2136830 new head: 981c729bdca928743f9bf6e7fc611563c312cbc3 ---------------------------------------------------------------------------- f1e81e6: Fix bug in BLayout::RemoveView(). Fix typo-induced bug causing (in many cases) the wrong item to be removed from the layout! Also, improve performance from O(n * m) to O(n), although n and m will always be quite small in practice, we might as well. 9f02923: Fix typo in BLayout::AllArchived(). BLayout::AllArchived() was forwarding to BArchivable, skipping BLayoutItem. 981c729: Fix potential uninitialized variable bug in BLayout::AllUnarchived(). BMessage::GetInfo() doesn't set the count output var in error cases. [ Alex Wilson <yourpalal2@xxxxxxxxx> ] ---------------------------------------------------------------------------- 1 files changed, 9 insertions(+), 7 deletions(-) src/kits/interface/Layout.cpp | 16 +++++++++------- ############################################################################ Commit: f1e81e617247b1c827755a31627325c33052407e URL: http://cgit.haiku-os.org/haiku/commit/?id=f1e81e6 Author: Alex Wilson <yourpalal2@xxxxxxxxx> Date: Thu Dec 29 05:29:58 2011 UTC Fix bug in BLayout::RemoveView(). Fix typo-induced bug causing (in many cases) the wrong item to be removed from the layout! Also, improve performance from O(n * m) to O(n), although n and m will always be quite small in practice, we might as well. ---------------------------------------------------------------------------- diff --git a/src/kits/interface/Layout.cpp b/src/kits/interface/Layout.cpp index 371588b..75d3932 100644 --- a/src/kits/interface/Layout.cpp +++ b/src/kits/interface/Layout.cpp @@ -200,16 +200,18 @@ BLayout::RemoveView(BView* child) bool removed = false; // a view can have any number of layout items - we need to remove them all - BView::Private viewPrivate(child); - for (int32 i = viewPrivate.CountLayoutItems() - 1; i >= 0; i--) { - BLayoutItem* item = viewPrivate.LayoutItemAt(i); + int32 remaining = BView::Private(child).CountLayoutItems(); + for (int32 i = CountItems() - 1; i >= 0 && remaining > 0; i--) { + BLayoutItem* item = ItemAt(i); - if (item->Layout() != this) + if (item->View() != child) continue; RemoveItem(i); - removed = true; delete item; + + remaining--; + removed = true; } return removed; ############################################################################ Commit: 9f0292314dc414b8f0294ddd7a87d0d69d9d5960 URL: http://cgit.haiku-os.org/haiku/commit/?id=9f02923 Author: Alex Wilson <yourpalal2@xxxxxxxxx> Date: Thu Dec 29 05:37:59 2011 UTC Fix typo in BLayout::AllArchived(). BLayout::AllArchived() was forwarding to BArchivable, skipping BLayoutItem. ---------------------------------------------------------------------------- diff --git a/src/kits/interface/Layout.cpp b/src/kits/interface/Layout.cpp index 75d3932..bce47bc 100644 --- a/src/kits/interface/Layout.cpp +++ b/src/kits/interface/Layout.cpp @@ -456,7 +456,7 @@ BLayout::Archive(BMessage* into, bool deep) const status_t BLayout::AllArchived(BMessage* archive) const { - return BArchivable::AllArchived(archive); + return BLayoutItem::AllArchived(archive); } ############################################################################ Revision: hrev43570 Commit: 981c729bdca928743f9bf6e7fc611563c312cbc3 URL: http://cgit.haiku-os.org/haiku/commit/?id=981c729 Author: Alex Wilson <yourpalal2@xxxxxxxxx> Date: Thu Dec 29 05:50:25 2011 UTC Fix potential uninitialized variable bug in BLayout::AllUnarchived(). BMessage::GetInfo() doesn't set the count output var in error cases. ---------------------------------------------------------------------------- diff --git a/src/kits/interface/Layout.cpp b/src/kits/interface/Layout.cpp index bce47bc..6b87372 100644 --- a/src/kits/interface/Layout.cpp +++ b/src/kits/interface/Layout.cpp @@ -468,7 +468,7 @@ BLayout::AllUnarchived(const BMessage* from) if (err != B_OK) return err; - int32 itemCount; + int32 itemCount = 0; unarchiver.ArchiveMessage()->GetInfo(kLayoutItemField, NULL, &itemCount); for (int32 i = 0; i < itemCount && err == B_OK; i++) { BLayoutItem* item;