Update BLayout::ItemAdded() and BLayout::ItemRemoved() to take an int32 index parameter, and ItemAdded() to return a bool indicating success or failure. Update BLayout::AddItem() to take the result of ItemAdded() into account. Also update BLayout::AllUnarchived() to take this into account. In either situation, if ItemAdded() returns false, the item does not get added to the layout. Removed various TODOs about code that could be removed once this change was made. In BSplitLayout, an item's LayoutData was lazy-initialized, but would always be created during ItemAdded(). Now we create the LayoutData explicitly, so that we can catch failed memory allocations. Closes #5524.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37817 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -36,8 +36,8 @@ public:
|
||||
static BArchivable* Instantiate(BMessage* from);
|
||||
|
||||
protected:
|
||||
virtual void ItemAdded(BLayoutItem* item);
|
||||
virtual void ItemRemoved(BLayoutItem* item);
|
||||
virtual bool ItemAdded(BLayoutItem* item, int32 atIndex);
|
||||
virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex);
|
||||
|
||||
private:
|
||||
BSize fMin;
|
||||
|
||||
@@ -63,8 +63,8 @@ public:
|
||||
BLayoutItem* item, int32 index);
|
||||
|
||||
protected:
|
||||
virtual void ItemAdded(BLayoutItem* item);
|
||||
virtual void ItemRemoved(BLayoutItem* item);
|
||||
virtual bool ItemAdded(BLayoutItem* item, int32 atIndex);
|
||||
virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex);
|
||||
|
||||
virtual bool HasMultiColumnItems();
|
||||
virtual bool HasMultiRowItems();
|
||||
|
||||
@@ -45,8 +45,8 @@ public:
|
||||
BLayoutItem* item, int32 index);
|
||||
|
||||
protected:
|
||||
virtual void ItemAdded(BLayoutItem* item);
|
||||
virtual void ItemRemoved(BLayoutItem* item);
|
||||
virtual bool ItemAdded(BLayoutItem* item, int32 atIndex);
|
||||
virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex);
|
||||
|
||||
virtual void PrepareItems(enum orientation orientation);
|
||||
|
||||
|
||||
@@ -60,10 +60,8 @@ public:
|
||||
virtual status_t ItemUnarchived(const BMessage* from,
|
||||
BLayoutItem* item, int32 index);
|
||||
protected:
|
||||
// TODO: Since memory allocations can fail, we should return a bool and
|
||||
// undo the addition, if false.
|
||||
virtual void ItemAdded(BLayoutItem* item);
|
||||
virtual void ItemRemoved(BLayoutItem* item);
|
||||
virtual bool ItemAdded(BLayoutItem* item, int32 atIndex);
|
||||
virtual void ItemRemoved(BLayoutItem* item, int32 fromIndex);
|
||||
|
||||
private:
|
||||
friend class BView;
|
||||
|
||||
Reference in New Issue
Block a user