[fpc-devel] TComponent.Tag type
Marc Weustink
marc.weustink at cuperus.nl
Thu Mar 20 11:05:00 CET 2008
Graeme Geldenhuys wrote:
>> This has been discussed before:
>> http://www.mail-archive.com/fpc-devel@lists.freepascal.org/msg05895.html
>>
>> It could be problematic if a Tag is streamed and read on different platforms. It
>> would better to introduce a new (non streamable) SizeInt property.
>>
>
> In fpGUI I introduced the following...
>
> public
> property TagPointer: Pointer read FTagPointer write FTagPointer;
>
>
> Non-streamable, but handy. Would that work?
At work I completely abanonded putting pointers in tags, but I use a Map
like object inbetween:
on create:
SomeObject.Tag := GetnextTagSequence;
ObjectMap.Add(someObject.Tag, someObject);
on use:
if ObjectMap.GetData(someObject.Tag, someObject) then
someObject.dosomething
On destroy of SomeObject is is removed form the map. Advantage is that
if the tag is passed to different routines, if the map cant find the
object, it is destroyed, so you never reference a destroyed object.
Marc
More information about the fpc-devel
mailing list