Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Objects in a collection - destroy() doesn't fire
Message
 
 
À
18/04/2007 16:24:39
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Versions des environnements
Visual FoxPro:
VFP 9 SP1
Divers
Thread ID:
01217484
Message ID:
01217487
Vues:
28
Who is destroying first: parent or child? I think you need to do something else, storing a reference to the parent in the child object referenced in the parent will put you in trouble (already did).

>I have a custom object with a collection object added via Add Object. This collection contains a bunch of other custom objects, created via NewObject() function.
>
>At some point, I needed a reference to the top level object from some of the objects in the collection. I passed it as a parameter and stored in a custom property. To clean up, in the destroy() of these custom object I have a
>
>this.oParent=null
>
>but it seems that the destroy never fires. I've set breakpoints at various places. I've even tried to loop through the collection, like this:
>
>
	FOR EACH oitem IN this.octls
>		oitem.oparent=null
>		oItem=null
>	ENDFOR
>	this.RemoveObject("oCtls")
>
>but it doesn't seem to change anything - the form where this all happens won't release if any of the item objects have ever set the .oParent to the master object. If I don't visit the code where it's set, everything's fine.
>
>Should I just add these as children of the master object, i.e. via this.newobject(), and just store a reference to them in the collection? I do need the collection so I can find the object when needed - they are created ad hoc and there can be an arbitrary number of them.
>
>Or is there another cause why my references keep dangling?
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform