[fpc-devel] Propose: change TComponent.Tag from longint to PtrInt
Michael Van Canneyt
michael at freepascal.org
Mon Sep 4 13:11:34 CEST 2006
On Mon, 4 Sep 2006, peter green wrote:
>>> 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
A pointer cannot be stored anyway at design-time, so it does not need to be
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.
More information about the fpc-devel