Mike Lewis
Programmer
I feel this should be simple, but I can't get my head round it.
I have a class which creates an object reference to another class (a timer). In doing so, it passes an object reference to itself to the timer.
In other words, the code looks like this (highly simplified):
This is all working fine, except that I can't release the object based on MyClass. I can see RELEASE goMyObject being executed in the debugger, but the Destroy doesn't get executed, and the object is still in memory when the program is ready to close.
Clearly, the fact that the main class stores a reference to the timer, and the timer stores a reference to the main clause, is upsetting VFP. But I can't see how to get round it.
Any insights will be appreciated.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
My Visual FoxPro site: www.ml-consult.co.uk
I have a class which creates an object reference to another class (a timer). In doing so, it passes an object reference to itself to the timer.
In other words, the code looks like this (highly simplified):
Code:
goMyObject = CREATEOBJECT("MyClass")
* Other processing here
RELEASE goMyObject
RETURN
DEFINE CLASS MyClass AS Session
oTimer = NULL
FUNCTION INIT
THIS.oTimer = CREATEOBJECT("MyTimer", THIS)
ENDFUNC
FUNCTION DESTORY
THIS.oTimer = NULL
ENDFUNC
ENDEFINE
DEFINE CLASS MyTimer AS Timer
oCaller = NULL
FUNCTION INIT
LPARAMETER toCaller
THIS.oCaller = toCaller
ENDFUNC
FUNCTION DESTROY
THIS.oCaller = NULL
ENDFUNC
ENDDEFINE
This is all working fine, except that I can't release the object based on MyClass. I can see RELEASE goMyObject being executed in the debugger, but the Destroy doesn't get executed, and the object is still in memory when the program is ready to close.
Clearly, the fact that the main class stores a reference to the timer, and the timer stores a reference to the main clause, is upsetting VFP. But I can't see how to get round it.
Any insights will be appreciated.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
My Visual FoxPro site: www.ml-consult.co.uk