How to correctly stream a TCollection property of a subcomponent, e.g. the Columns property of an embedded TDBGrid

前端 未结 2 1600
执笔经年
执笔经年 2020-12-21 04:04

I\'ve been trying to boil down to an MCVE some code the author of another q sent me to illustrate a problem with a custom component.

The component is simply a TPanel

2条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-21 04:20

    Seems there is not much you can do about it. When you look into procedure WriteCollectionProp (local to TWriter.WriteProperties) you see that FPropPath is cleared before the call to WriteCollection.

    The problem with TDBGrid, or better TCustomDBGrid, is that the collection is marked as stored false and the streaming is delegated to DefineProperties, which uses TCustomDBGrid.WriteColumns to do the work.

    Inspecting that method reveals that, although it also calls WriteCollection, the content of FPropPath is not cleared before. This is somewhat expected as FPropPath is a private field.

    The reason why it nonetheless works in the standard use case is that at the moment of writing FPropPath is just empty.

    As even Delphi 10.1 Berlin behaves the same as Delphi 7, I suggest filing a QP report together with just this example.

提交回复
热议问题