Lazarus
Programming => General => Topic started by: jamie on August 29, 2024, 01:43:34 am
-
using the TFPGMAP's Clear, Remove and delete
The Docs are not clear on using, CLEAR, REMOVE and DELETE.
I have for the data part of the keys Classes, objects etc. Does the code also call the .FREE on these items ?
it does state that it gets removed from memory, I can only assume it means the managed array of the keys and data items.
But it also states down in the base classes far from this class, depending on the data descendant, it may also delete that too.
Does the destructor get called on these items using this generic?
-
Looks like I need to use the TFpgMAPObject if I expect auto destructor calls on Clear, Delete etc.
I think the DOCs need touching up because I had to run test app to figure out which was which.
only the OBJECT types will free them.
-
Actually there is a class function ItemIsManaged that may help you.
It is in the TFpsList ancestor, the root class above Tobject.
-
TFPGMapObject constructor (https://www.freepascal.org/docs-html/current/rtl/fgl/tfpgmapobject.create.html) takes the boolean parameter AFreeObjects. If set, the objects are freed when removed.
This doesn't seem to be documented though (no explanation of the parameter in the page linked above).
TFPGMap does not seem to have this.