Hi,

The correct function is being called, its just half way through loading my world file it just goes to the end of the worlds main loadfromfile function to early, below is a more complete code:

[pascal]
procedure XShellLoadDefaultWorld;
begin
Log(PChar('loading default world..'));
World.LoadFromFile(XShellDataDir+'defaultworld.xsw ');
SetupDefaultSpawn;
SetupActor;
end;

procedure TxseWorld.LoadFromFile(const Filename: String);
var
Stream: TxnStream;
i,Cnt: Integer;
oClass: String;
begin
Stream := TxnStream.Create(Filename, xmOpenRead);
If ValidHeader(Stream, WORLD_HEADER) Then
Begin
Clear;
Worldspawn.LoadFromStream(Stream);
Stream.ReadInteger(Cnt);
For i := 0 To Cnt-1 Do
Begin
Stream.ReadString(oClass);
Objects.Add('', oClass);
Objects[i].LoadFromStream(Stream);
End;
End;
Stream.Free;
end;

function TxseObjects.Add(const Name,Classname: String): Integer;
var
nObject: TxseBaseObject;
begin
Result := -1;
If fOwner = Nil Then
Begin
If Not xseObjectRegister.IsAllowed('', Classname) Then Exit;
End Else
Begin
If Not xseObjectRegsiter.IsAllowed(fOwner.oClassname, Classname) Then Exit;
End;
nObject := xseObjectRegister.GetClass(Classname).Create(Self) ;
If nObject = Nil Then Exit;
nObject.Name := Name;
nObject.oClassname := Classname;
Result := inherited Add(nObject);
nObject.Index := Result;
end;

procedure TxseBaseObject.LoadFromStream(const Stream: TxnStream);
var
i,Cnt,Index: Integer;
oClass: String;
begin
Stream.ReadString(Name);
Stream.ReadInteger(Cnt);
If Children <> Nil Then
Begin
Children.Clear;
For i := 0 To Cnt-1 Do
Begin
Stream.ReadString(oClass);
Children.Add('', oClass);
Children[i].LoadFromStream(Stream);
End;
End;
end;

begin
//main application code
while GameRunning Do
Begin
//code
End;
// finalize code
end.
[/pascal]

The xseObjectRegister is a list of all my world class types, such as groups, polygons, faces, particle systems, lights, etc..

Both Objects and Children are TxseObjectList class types (which is derived from TList), which are a list of TxseBaseObject.

In the world.loadfromfile procedure the app runs in to the for statement and starts to load the objects, the first object has 11 children some with a child, when it trys to load the 5th child it then exits this procedure and goes back into world.loadfromfile to stream.free, then goes to the end of my applications code where the //finalize code is and then goes back to where it was in the objects loadfromstream procedure, but by this time it crashes because it trys to read something from the stream, but it has been released :s

I have renamed all the procedures to check see if they are being called some where else but this isnt happening.. :s