Information générale
Catégorie:
Codage, syntaxe et commandes
Not really. If the variable that keeps the reference to the object created with CreateObject() (oCO) is a property of an other object, than the object oCO will be destroyed automatically when its parent is destroyed. So, there is no real difference here compared with an object created with AddObject(). More generic, the object created with CreateObject will be destroyed when its reference is destroyed or changed. That means an object is destroyed when there are no vars or properties that keep reference to that object.
So:
*-- The new object will be destroyed when MyVar goes out of scope, anyway.
MyVar = CreateObject("Label")
MyVar = .f. && Now, the previous object was destroyed.
MyVar = CreateObject("Label")
release MyVar && Now, the previous object was destroyed.
*-- The new object will be destroyed when MyForm will be destroyed, anyway.
MyForm.AProperty = CreateObject("Label")
MyForm.AProperty = CreateObject("Relation") && The Label object was destroyed
MyForm.AProperty = 1 && The Relation object was destroyed
MyForm.AProperty = CreateObject("Custom")
release MyForm && The Custom object was destroyed
It's a little more complicate when 2 vars/properties keep a reference to the same object... :)
Vlad
>In addition to that, an object created with AddObject will go away nicely when the container object goes away. An object created with CreateObject has to be destroyed by your own code. (is that right?)
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement