Einzelnen Beitrag anzeigen

ford42

Registriert seit: 2. Okt 2015
60 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#7

AW: Warum geht FreeAndNil nicht?

  Alt 6. Aug 2018, 10:53
Mein Sourcecode ist doch oben?

EDIT: Die Methode sah eig vorher so aus:

Delphi-Quellcode:
procedure TForm1.Bt_DeleteClick(Sender: TObject);
var
  PBufferNode: PNode;
begin
  if PCurrentNode.previous <> nil then
  begin
    PCurrentNode := PCurrentNode.previous;
    PBufferNode := PCurrentNode.next;
    if PCurrentNode.next.next <> nil then
    begin
      PCurrentNode.next := PCurrentNode.next.next;
    end
    else
    begin
      PCurrentNode.next := nil;
    end;
    if PBufferNode.next <> nil then
    begin
      PBufferNode.next.previous := PBufferNode.previous;
    end;
    //PBufferNode := nil;
    Refresh;
    //PBufferNode.previous := nil;
    //PBufferNode.next := nil;
    FreeAndNil(PBufferNode);
  end
  else if PCurrentNode.next <> nil then
  begin
    PCurrentNode := PCurrentNode.next;
    PBufferNode := PCurrentNode.previous;
    if PCurrentNode.previous.previous <> nil then
    begin
      PCurrentNode.previous := PCurrentNode.previous.previous;
    end
    else
    begin
      PCurrentNode.previous := nil;
    end;
  FreeAndNil(PBufferNode);
  Refresh;
  end
  else
  begin
    FreeAndNil(PCurrentNode);
    //PCurrentNode := nil;
    Bt_Back.Enabled := False;
    Bt_Vorward.Enabled := False;
    RefreshLbl;
  end;
end;
  Mit Zitat antworten Zitat