[fpc-pascal] Make TStringList.ExchangeItems virtual?
bartjunk64 at gmail.com
Wed Feb 13 15:43:06 CET 2013
Is it at all feasible to make TStringList.ExchangeItems a virtual method?
In Lazarus we have a component (TValueListEditor) that has a
TStringList descendant as one of it's properties.
This particular list needs te bee in sync with another list of objects.
For Insert, Delete, Exchange and Clear that is easily done.
However sorting is a problem, because CustomSort calls QuickSort which
internally uses ExchangeItem() and not Exchange (which is virtual).
For now I just duplicated the QuickSort and replaced ExchangeItem with
(the overridden) Exchange.
This however has the distinct disadvantage of having duplicate code.
And yes, I thought about storing the other objects inside the
stringlist, so they are automatically sorted as well, but then I would
get into trouble if some user decide to store objects inside this
stringlist (because he would not expect that this caused the component
to not function properly anymore).
Since I'm ignorant of possible side effects, I thought I'ld better
first ask here, before filing a feauture request on the bugtracker.
More information about the fpc-pascal