I looked at your solution for BookmarkValid.
I'm not sure that it is ok. If I compare it with conditions in SetToBookmark and CompareBookmarks I think that it could be write in another way...
Code: Select all
procedure TMemData.SetToBookmark(Bookmark: PRecBookmark);
...
  if (Bookmark.RefreshIteration = FRefreshIteration) and
    (IntPtr(Bookmark.Item) <> nil)
  then begin
....
  end;
// Set by order
  inherited;
end;
Code: Select all
function TMemData.CompareBookmarks(Bookmark1, Bookmark2: PRecBookmark): integer;
...
    if Bookmark1.RefreshIteration = Bookmark2.RefreshIteration then
      if Bookmark1.Item = Bookmark2.Item then begin
...
        if (IntPtr(Bookmark1.Item) <> nil) and (IntPtr(Bookmark2.Item) <> nil) then
          try // for freed item
            if Bookmark1.Item.Order >= Bookmark2.Item.Order then
              if Bookmark1.Item.Order = Bookmark2.Item.Order then
...
// Compare by order
  Result := inherited CompareBookmarks(Bookmark1, Bookmark2);
end;
Code: Select all
function TMemData.BookmarkValid(Bookmark: PRecBookmark): boolean;
begin
  if IntPtr(Bookmark) <> nil then
    begin
      if (Bookmark.RefreshIteration = FRefreshIteration) and (IntPtr(Bookmark.Item) <> nil) then
        Result := (Bookmark.Item.Order <= FRecordCount)
      else
        Result := (Bookmark.Order <> -1) and (Bookmark.Order <= FRecordCount);
    end
  else
    Result := False;
  if Result and Filtered then
    Result := not OmitRecord(Bookmark.Item);
end;
Thanks
Roman Krupicka