Opened 6 years ago

Last modified 4 months ago

#9627 assigned enhancement

Fix problematic default value for BObjectList::RemoveItem() deleteIfOwning parameter

Reported by: bonefish Owned by: nobody
Priority: normal Milestone: R2
Component: Kits/Support Kit Version: R1/Development
Keywords: Cc: rossi@…
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

This has bitten me more than once already: When a BObjectList is owning its elements the call RemoveItem(myObject) deletes the supplied object. This is problematic for the following reasons:

  • The method is called *Remove*Item() which does not imply that the item is deleted.
  • The behavior differs from RemoveItemAt() which never deletes the object.

The change causing the least work would be to just remove the default value for the deleteIfOwning parameter. Then the API user does have to explicitly decide whether the deletion is desired or not and it is far less likely that it happens accidentally. This solution is not so great for the not-owning case, though.

A cleaner solution (though possible troublesome for third-party developers) would be to remove the parameter altogether, change the method not to delete the object, and introduce a DeleteItem() or EraseItem() method. Besides making it even less likely to accidentally delete the object (it's way more obvious than a true/false argument) such a method would also make sense for lists that aren't owning the items.

Change History (3)

comment:1 Changed 6 years ago by rossi

Cc: rossi@… added

comment:2 Changed 2 years ago by axeld

Owner: changed from axeld to nobody
Status: newassigned

comment:3 Changed 4 months ago by waddlesplash

Milestone: R1R2
Note: See TracTickets for help on using tickets.