Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Automatic Destroy method
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01246863
Message ID:
01247733
Views:
37
This message has been marked as a message which has helped to the initial question of the thread.
Hi Naomi,

>How can I use this class for my existing application where I suspect dangling references?

It's less about using the class, more about incorporating its ideas into your own base classes. OK, let's break this into only a few modules... Add the following methods to your base classes:

- Release
- Cleanup
- DoCleanup
- DoClearReferences

and the following property:

- lCleanedUp = .F.

In the Cleanup method set lCleanedUp to .T. For containers call the CleanUp method of all contained controls. Then call DoCleanUp, then DoClearReferences. For normal controls only call DoCleanup and DoClearReferences. In the Release method put:
This.CleanUp()
RELEASE This
In the RemoveObject method put:
LOCAL loRef
loRef = GETPEM(This,cName)
loRef.CleanUp()
loRef = NULL
DODEFAULT(This.cName)
And in the destroy event put:
ASSERT This.lCleanedUp
IF NOT This.lCleanedUp
  THIS.CleanUp()
ENDIF
DoCleanUp() and DoClearReferences() are the two methods you use in sub classes. In DoClearReferences you place code that sets all object references in the object to NULL. In DoCleanUp put the code that disconnects the object from all other objects in a logical way, eg. deregister it from a manager class of some sort, and the like.

Now you should get an ASSERT message everytime you haven't properly cleaned up an object before VFP fired its Destroy event. Make sure you have SET ASSERTS ON to get notified. Your code to check object references would go into the CleanUp method after the DoClearReferences call.
--
Christof
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform