Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to destroy class property
Message
From
26/12/2007 11:43:18
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9 SP2
Miscellaneous
Thread ID:
01277535
Message ID:
01277557
Views:
22
>>>I have a business class that has a property DA_OBJECT referencing data access class. The DA_OBJECT is instantiated in the INIT method of the business class. I need to destroy the DA_OBJECT when the business class is destroyed. Since my business class is based on the CUSTOM class I am thinking to add the following in the Destroy method:
>>>
>>>
>>>this.DA_OBJECT = .NULL.
>>>dodefault()
>>>
>>>
>>>Is the above correct approach?
>>>
>>>Thank you in advance.
>>>
>>>UPDATE: I am actually using VFP 9 SP1 (not SP2).
>>
>>I think it is correct. I have seen this in the framework I use, pressumably to avoid dangling references (which can sometimes cause the form not to close completely).
>
>
>They always keep the form alive, don't they?

Yeah, I think the problem arises when an object A has a reference to object B - and vice versa. An object is destroyed when it has zero object references, but this "deadly embrace" can avoid either of the two objects from being destroyed. And both objects might be properties on the same form. But I don't know much more about this; like, being able to give specific repro code.

I also understand that this is different in languages that use garbage collection (like Java, for instance), where the two objects, in the above example, are unreachable from some initial set of objects, and will eventually be destroyed.
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Reply
Map
View

Click here to load this message in the networking platform