Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Releasing internal object references.
Message
 
To
06/10/1998 13:13:29
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00144275
Message ID:
00144292
Views:
19
Hi Erik,

>I think I know the answer to this, but just in case there is a strategy I don't know about...
>In the past when I have an object on a form that holds a reference to another form object, I have just set o1.oRef = .NULL. in the form.destroy. This has been fine because this design was happening at the form level.
>I am now trying to create a class that has to hold a reference to another object on the form, and I would like for the class to watch out for itself. I quickly found that THIS.oRef = .NULL. in the object's destroy event won't do the trick. Is there another way to make this class self sufficient? IOW, I don't want to have to rely on form code to release the object.

No, but you can come close to that by adding the following code to the Destroy event of all of your base classes that contain objects (adjust the name of the collection, ie pages for the pageframe, etc):
For lnControl = This.ControlCount to 1 Step -1
   This.RemoveObject(This.Controls[m.lnControl])
Endfor
Another (ugly) possibility is to modify the instanciation order in a way that the control that holds the reference is released prior to the control that the reference points to.

Christof
--
Christof
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform