如何处理数据快照服务器中的对象引用?
我有返回 TUser 对象的 Datasnap 服务器方法
TServerMethods.CurrentUser(const AId: Integer): TUser
begin
Result := GlobalCurrentUser; // <- Don't want to free this object
Result.AddReference;
end;
TReferencedObject 子类中的 TUser
TReferencedObject = class(TObject)
private
FReferenceCnt: integer;
public
procedure AddReference; virtual;
procedure RemoveReference; virtual; // Frees object if reference count goes to 0
property ReferenceCnt: integer Read FReferenceCnt Write FReferenceCnt;
end;
目前 DataSnap 服务器释放 TUser 对象,但我想为 TReferencedObject 后代调用 RemoveReference。