Is this a bug?
BlitzMax Forums/BlitzMax Beginners Area/Is this a bug?| 
 | ||
| It seems these types should be deleted at flushmem, but theyre not. What am I missing here? 
Type BaseObject
	Global list:TList
	Global IDCount
	Field ID
	
	Function Get_Object:BaseObject(_ID)
		Local o:baseobject
		For o = EachIn List
			If o.ID = _ID Then
				Return o
			End If
		Next
		Return Null
	End Function
	
	Method New()
		If List = Null Then List = CreateList()
		list.Addlast(Self)
		IDCount :+ 1
		ID = IDcount
		Print("BaseObj::New()")
	End Method
	
	Method Get_ID:Int()
		Return ID
	End Method
	
	Method Delete()
		List.Remove(Self)
		If CountList(List) = 0 Then list = Null
	End Method
End Type
Type Testtype Extends BaseObject
	Field A
	Field B	
	
	Method New()
		Print("Testype::New()")
	End Method
	
	Method Delete()
		Print("Testype::Delete()")
	End Method
	
		'-----------------------
	Function Create_Test()
		Local Test:Testtype
		test = New testtype
		Return test.ID
	End Function
	
End Type
Local A:testtype = New testtype
Notify a.Get_ID()
Local B:testtype = New testtype
Notify B.Get_ID()
B = Null
A = Null
FlushMem
FlushMem
Print CountList(A.list)
End
 | 
| 
 | ||
| Test this one: 
Type BaseObject
	Global list:TList
	Global IDCount
	Field ID
	Field Link:TLink
	Function Get_Object:BaseObject(_ID)
		Local o:baseobject
		For o = EachIn List
			If o.ID = _ID Then
				Return o
			End If
		Next
		Return Null
	End Function
	
	Method New()
		If List = Null Then List = CreateList()
		Link=list.Addlast(Self)
		IDCount :+ 1
		ID = IDcount
		Print("BaseObj::New()")
	End Method
	
	Method Get_ID:Int()
		Return ID
	End Method
	
	Method Remove()
		Link.Remove()
		If CountList(List) = 0 Then List=Null;Print "List is Emty!"
		Flushmem()
	End Method
End Type
 
Type Testtype Extends BaseObject
	Field A
	Field B	
	
	Method New()
		Print("Testype::New()")
	End Method
	
	Method Delete()
		Print("Testype::Delete()")
	End Method
	
		'--------e---------------
	Function Create_Test()
		Local Test:Testtype
		test = New testtype
		Return test.ID
	End Function
	
End Type
 
Local A:testtype = New testtype
Notify A.Get_ID()
Local B:testtype = New testtype
Notify B.Get_ID()
A.Remove()
B.Remove()
B = Null
A = Null
FlushMem
FlushMem
End
 | 
| 
 | ||
| Thanks Tiger, But why is the code I posted above not working propery? It seems it should. is it a bug? |EDIT| Oh.. Nevermind. heheh. I understand now.. duh :) |