[fpc-devel] Propose: change TComponent.Tag from longint to PtrInt

Marc Weustink marc.weustink at cuperus.nl
Mon Sep 4 14:07:51 CEST 2006

Marc Weustink wrote:
> Michael Van Canneyt wrote:
>> On Mon, 4 Sep 2006, peter green wrote:
>>>>> Me2.
>>>>> Just one disadvantage:
>>>>> The Tag is published.
>>>>> If someone stores a 64bit value and the component is stored,
>>>>> the stream can not be read under 32bit anymore.
>>>> ...which makes it impossible to use streams for anything derived from
>>>> Tcomponent, which is really a lot. I don't think we should break this
>>>> feature to allow broken code to work.
>>> ahh the joys of conflicting requirements,
>>> I don't consider storing a pointer in the tag is broken code, it was
>>> considered the accepted way to maintain a pointer to your custom data 
>>> from a
>>> standard control and there is often no simple alternative.
>> Accepted only because there was no other way.
>> The only correct way is to introduce an additional field 'UserData', 
>> of type Pointer.
>> A pointer cannot be stored anyway at design-time, so it does not need 
>> to be published.
>> Remains the decision where you introduce this pointer: TComponent, 
>> TControl.
>> IMHO, you should introduce TLCLComponent, add it there, and descend 
>> all LCL components from that.
> TLCLComponent is already exists (it's only not committed yet.
> Adding a UserData to it is maybe an idea.
> THis will work for most compoenents, except DB components for instance.

Whoops, as Vincent reminded me, it is already there (I confused it with 
another uncommitted class)


More information about the fpc-devel mailing list