Hi,
I'm having a bit of a problem with getting properly rid of a type.
The thing I'm doing is I have a controller, which keeps track of everything going on. When killing this controller (using a custom function) it releases all the other types used in the game/program....Or...It should release everything, but cannot if you have made an external reference to something. So the big question is:
How do you kill a type properly, when there are still references to it somewhere?
Here's some code to demonstrate what I am on about:
I'm having a bit of a problem with getting properly rid of a type.
The thing I'm doing is I have a controller, which keeps track of everything going on. When killing this controller (using a custom function) it releases all the other types used in the game/program....Or...It should release everything, but cannot if you have made an external reference to something. So the big question is:
How do you kill a type properly, when there are still references to it somewhere?
Here's some code to demonstrate what I am on about:
Global con:controller Type test Field something:Int Function Create:test(something:Int) Local t:test = New test t.something = something con.everything.addlast t Return t End Function End Type Type controller Field everything:TList = New TList Function Init() If con con.Kill() EndIf Print "Initializing Controller" con:controller = New controller End Function Function Kill() If con Print "Killing Controller!" For Local t:test = EachIn con.everything Print "Releasing: "+t.something Release t Next Release con.everything Release con con = Null FlushMem EndIf End Function End Type controller.init() hello:test = test.Create(129) Print hello.something controller.kill ' ' This should be removed but isn't ??? Print hello.something