Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cycle Reference
Message
From
13/01/2004 19:31:41
Erick Miranda
Formata Data Business - Grupo Linx
Contagem, Brazil
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Title:
Cycle Reference
Miscellaneous
Thread ID:
00866550
Message ID:
00866550
Views:
56
Hi!

I need to create one class (Dad) and within this class Dad I will have an other class (Son).
Inside of the class Son need have one reference of the Dad, or be, I have a Cycle Reference, only that with this I can't release theses class, they stay in memory.
Do you know any way to intercept when the class is going release to can remove the reference of class Dad in Son before?
Follow sample code:
DEFINE CLASS dad as Custom
	son = null
	PROCEDURE init()
		this.son = CREATEOBJECT([son])
		this.son.dad = this
	ENDPROC
	PROCEDURE destroy()
		MESSAGEBOX([Dad - Destroy])
	ENDPROC
ENDDEFINE
***--------------------------------***
DEFINE CLASS son as Custom
	dad = null
	PROCEDURE init()
	ENDPROC
	PROCEDURE destroy()
		MESSAGEBOX([Son - Destroy])
	ENDPROC
ENDDEFINE
To do a test:
1: Create one PRG (MyPrg, for sample)
2: In Command Window do:
   - Set Procedure To MyPrg
   - X = CREATEOBJECT([Dad])
   - Release X 
   - In this moment don't appear any message, but if you to comment the 
     line "this.filho.pai = this" the messages of the Destroy event appear.
P.S.: I trying to use the Destroy, Unload, QueryUnload events, but didn´t work. I'm using VFP8 and W2K Professional. Sorry my bad English!
Thanks!
Erick
Força Sempre!
Strength Always!
Next
Reply
Map
View

Click here to load this message in the networking platform