Recent

Author Topic: Question about using REMOVE,DELETE in TFPGMAP  (Read 1466 times)

jamie

  • Hero Member
  • *****
  • Posts: 7610
Question about using REMOVE,DELETE in TFPGMAP
« 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?
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 7610
Re: Question about using REMOVE,DELETE in TFPGMAP
« Reply #1 on: August 29, 2024, 03:11:48 am »
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.

The only true wisdom is knowing you know nothing

Thaddy

  • Hero Member
  • *****
  • Posts: 18797
  • Glad to be alive.
Re: Question about using REMOVE,DELETE in TFPGMAP
« Reply #2 on: August 29, 2024, 02:41:55 pm »
Actually there is a class function ItemIsManaged that may help you.
It is in the TFpsList ancestor, the root class above Tobject.
Recovered from removal of tumor in tongue following tongue reconstruction with a part from my leg.

Zoran

  • Hero Member
  • *****
  • Posts: 1988
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Question about using REMOVE,DELETE in TFPGMAP
« Reply #3 on: August 29, 2024, 08:23:41 pm »
TFPGMapObject constructor 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.

« Last Edit: August 29, 2024, 08:25:23 pm by Zoran »
Swan, ZX Spectrum emulator https://github.com/zoran-vucenovic/swan

 

TinyPortal © 2005-2018