Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Any way to find dangling references?
Message
From
08/02/2008 03:24:37
 
 
To
08/02/2008 02:54:24
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01288201
Message ID:
01290745
Views:
24
This would be my idea of a forcerelease method making use of ainstance() and giving feedback on what it did try to kill,including THIS - untested:
Procedure forcerelease()
   Local Array lainstances[1]
   Ainstance(lainstances,This.Class)
   Local lnCount, loReference
   For lnCount = 1 To Alen(lainstances,1)
      Try
         loReference = Evaluate(lainstances(lnCount))
      Catch
         Debugout "reference "+lainstances(lnCount)+" not accessible"
         loReference = .Null.
      Endtry
      If Vartype(loReference)="O"
         If Pemstatus(loReference,"cID",5) And loReference.cID=This.cID
            Try
               If !Pemstatus(loReference,"forcerelease",5)
                  * should never be the case as we try to force release of this class
                  * and this class has a forcerelease method.
                  Debugout "reference "+lainstances(lnCount)+" to "+This.Class+;
                     " without forcerelease() method!"
               Else
                  loReference = .Null.
                  Debugout "try to kill reference "+lainstances(lnCount)
                  Execscript(lainstances(lnCount)+" = .null.")
                   * side note: There is no need to call forcerelease of that instance, 
                   * as we already loop over every instance...
               Endif
            Catch
               Debugout "failed to kill reference "+lainstances(lnCount)
            Endtry
         Endif
      Endif
      loReference = .Null.
   Endfor
   Debugout "try to kill THIS"
   THIS = .null.
Endproc
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform