Hi,
in an old project (webapp), which I developed when I was new to xojo, I wrote some code with circle references.
My questions:
- how can I easily detect circle references?
- how can I avoid or remove circle references without the need to rewrite big parts of my code?
Thanks
Never worked with.
How can I transform a property, which holds a circle reference into a weak ref?
One easy way is to use Computed Properities. Lets say you had a property named Parent as Session
- Right click and convert it. Itll create a new private property named mParent and a getter/setter pair where the property was.
- Change mParent type to WeakRef.
- In the Setter change the code to mParent = new WeakRef(value).
- In the Getter use this:
if mParent = Nil or mParent.value = Nil then
Return Nil
Else
Return Session(mParent.Value)
End if
Once youve done this, youll also need to protect your code against this property returning Nil if the Session has gone away, whether by checking for Nil or using exception handling.