Jump to content

Rainer Wolff

Members
  • Content Count

    1
  • Joined

  • Last visited

Everything posted by Rainer Wolff

  1. Hello, i have the following lines: class function TToollist.GetItemById(Index: Integer): TTool; var w:TTool; begin result := nil; for w in Toollist do begin if w.oid = Index then result := w; end; end; class function TToollist.GetToollist: IList<TTool>; begin if not Assigned(FToollist) then begin FToollist:=TCollections.CreateObservableList<TTool>; FToollist.AddRange(dm.Session.FindAll<TTool>); // FToollist:=dm.Session.FindAll<TTool>; end; Result:=FToollist; end; My property Toollist is touched for the first time by fetching an Item by Id, the getter finds FToollist not yet assigned, creates it and reads its data from database, using spring4d orm. I want the Items to be in an Observable list, so loading db and then adding to the List. But as soon as I leave the getter, my FToollist is freed via interface reference count and all my items are released. If I just load my items directly into the FToollist, as in the commented line instead of using CreateObservableList and adding range, everything is fine. My FToollist is a IList<TTool> in both cases. I'd like to learn the internals of this behaviour, can someone explain it to me?
×