Yesterday night I've lost half an hour because of an oddity in this component. The
OnFilterItem event has the following type:
TFilterItemEvent = function (Item: TObject; out Done: Boolean): Boolean of object;So for a TTreeView, I would have expect
Item to be cast-able to TTreeNode. After several violation accesses, I've looked at the sources and found that the event is actually called with
Item set to
TObject(TTreeNode.Data).
still in masterI found this very unsafe. A
TTreeNode.Data can be everything and there is no guarantee that it's an object. Also while debuging, a nil data casted as TObject is not displayed as nil, which can be quite confusing. Finally, as usual, there's no doc (description of the parameters, of the result, of how it's used), so the basic reaction I had after reading the sources is
Is this cast an error, shouldn't a TTreeNode be passed instead of its optional data ?
(even if I supose that it's too late to change this without breakage)