 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Debbie Erickson Guest
|
Posted: Fri Oct 24, 2003 5:38 pm Post subject: Deleteing TreeNodes |
|
|
Hi. In the Delphi help file for "AddObject" of a treenode says "The memory
referenced by Ptr is not freed when the tree nodes object is freed.".
Under the listing of DeleteChildren, it says "delete all children of a tree
node, freeing all associated memory." These seem to contradict each other.
Before I use the DeleteChildren, do I need to call "dispose" to free up the
pointer(s) for each affected node?
|
|
| Back to top |
|
 |
greybeard Guest
|
Posted: Fri Oct 24, 2003 6:21 pm Post subject: Re: Deleteing TreeNodes |
|
|
Hi, Debbie
| Quote: | Hi. In the Delphi help file for "AddObject" of a treenode says "The
memory
referenced by Ptr is not freed when the tree nodes object is freed.".
|
This is a pointer to a TreeNode.Data property, which points to your own
object unknown to TreeView. There is why it cannot be freed by TreeView
methods.
| Quote: | Under the listing of DeleteChildren, it says "delete all children of a
tree
node, freeing all associated memory." These seem to contradict each
other. |
TreeNode.DeleteChildren deletes all Nodes and frees all its memory,
including a Data property, but not the memory, to which the content of Data
points.
| Quote: | Before I use the DeleteChildren, do I need to call "dispose" to free up
the
pointer(s) for each affected node?
It depends on the character of objects, to which Data properties point. If |
these objects are created in "normal" way (TStringList.Create...), they will
be freed at the end of program. If they are created by New procedure, you
have to dispose the memory allocated before deleting of each node.
Best regards, Vlastik
|
|
| Back to top |
|
 |
Debbie Erickson Guest
|
Posted: Fri Oct 24, 2003 6:29 pm Post subject: Re: Deleteing TreeNodes |
|
|
Thanks, Greybeard. Have a great day! :)
Debbie
"greybeard" <vlastik.bartos (AT) seznam (DOT) cz> wrote
| Quote: | Hi, Debbie
Hi. In the Delphi help file for "AddObject" of a treenode says "The
memory
referenced by Ptr is not freed when the tree nodes object is freed.".
This is a pointer to a TreeNode.Data property, which points to your own
object unknown to TreeView. There is why it cannot be freed by TreeView
methods.
Under the listing of DeleteChildren, it says "delete all children of a
tree
node, freeing all associated memory." These seem to contradict each
other.
TreeNode.DeleteChildren deletes all Nodes and frees all its memory,
including a Data property, but not the memory, to which the content of
Data
points.
Before I use the DeleteChildren, do I need to call "dispose" to free up
the
pointer(s) for each affected node?
It depends on the character of objects, to which Data properties point. If
these objects are created in "normal" way (TStringList.Create...), they
will
be freed at the end of program. If they are created by New procedure, you
have to dispose the memory allocated before deleting of each node.
Best regards, Vlastik
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|