TCollection dispatches two Observer notifications when adding or deleting items
Original Reporter info from Mantis: luizamerico
-
Reporter name: Luiz Americo
Original Reporter info from Mantis: luizamerico
- Reporter name: Luiz Americo
Description:
When an item is inserted or deleted TCollection notifies the Observer twice: one through Notify (ooAddItem/ooDeleteItem) and other through Changed/Update(ooChange).
This prevents implementation of granular actions in the observer.
As an example if i have a TListView observing a TCollection.
Optimally, i would refresh all listview items on ooChange (Collection is sorted, unknown operations between batch updates etc) and only add or remove one listview item at ooAdd/DeleteItem.
As is current it will always refreshes all items.
In the other side, if ooChange is not sent when item is added/deleted and i want to refresh all listview items every time, is a lot easy. Just do
case Operation of ooChange, ooAddItem, ooDeleteItem: Refresh; end;
I can prepare a patch, if needed.
Mantis conversion info:
- Mantis ID: 25822
- Fixed in version: 3.0.0
- Target version: 3.0.0