Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Any way to find dangling references?
Message
De
08/02/2008 02:54:24
 
 
À
04/02/2008 13:16:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01288201
Message ID:
01290742
Vues:
24
>in prg and change by switch:
>#define _DangleFind .t.
>#if _DangleFind
> Define class custom_base as custom_dangle [of ... vcx] && in your case to have one set of "dangling-fix" classes
> enddefine
>#else
> Define class custom_base as custom
> enddefine
>#endif
>
>define custom_dangle as custom
> *-- Christoph's code
>enddefine

You would at least need a call to doinit() in init() of custom_base, if you moved all your classes init() code.
It's a bit of a pain to change all your classes. But this is more easy than having a dodefault() in all init's first lines, because then the problem would be where to call postinit(). You need to rethink your init code anyway in that respect. Christof also already has advice to make use of #IF #ELSE #ENDIF in dependance of a debug constant defined or not.

Another way could be to force each createobject to be done by a factory class/object, where you gain more control about which references are there created when and how many. I also haven't seen Christof making use of AInstances(), maybe because this is only giving you instaces of a class stored in variables or arrays and created by createobject() or newobject() function, but not ones created with addobject() or newobject() methods. I think those are less of a problem, when it's about dangling references. They should only cause a destroy of their parent objects to fail, if there are again variable/array stored references to them. So implementing a release() method which tries to destroy all references found by ainstances() may also be a chance of a failsafe destroy. Just be careful that ainstances() is about instances of a certain class, not references of THIS object. So the array of instances needs to be checked with eg compobj(). Something like Christof's cID would of course help very much to identify references to the same object.

Bye, Olaf.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform