Am 01.07.2018 um 04:14 schrieb Michalis Kamburelis:
  2018-07-01 4:01 GMT+02:00 Vojtěch Čihák <vojtech.ci...@atlas.cz>:
this seems to be misleading error message. TFPGObjectList works well for
objects (classes). When I tried to push record to it, I got the same error
message. TVec3 is not class, right?
Indeed, it's a misleading message. The message

    ...identifier idents no member "Free"

doesn't talk about the line

     list.Free;

(which is fine, "list" is an instance of a class). It talks most
likely about the "Free" call inside FGL implementation in

"""
procedure TFPGObjectList.Deref(Item: Pointer);
begin
   if FFreeObjects then
     T(Item^).Free;
end;
"""

If you look inside the FGL unit sources of your FPC version, you will
likely find this to be at line 992 :)

Short explanation:Since your TVec3 is probably not a class, you cannot
do "Free" on it.

The solution is to use TFPGList instead of TFPGObjectList. You should
also define an equality operator if TVec3 is a record. See e.g. my
example in 
https://castle-engine.io/modern_pascal_introduction.html#_operator_overloading
(scroll to the example with TMyRecordList).
I've now added a TObject constraint to TFPGObjectList and the TData parameter of TFPGObjectMap. Sadly I can't add it to TFPGInterfacedObjectList or TFPGInterfacedObjectMap as currently both interfaces and objects implementing interfaces can be used.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to