* Fixed bug on ListItems.Delete

git-svn-id: trunk@1542 -
This commit is contained in:
lazarus 2002-03-24 16:38:01 +00:00
parent 08109d2171
commit 790daedb9c
3 changed files with 28 additions and 6 deletions

View File

@ -420,7 +420,8 @@ type
private private
FOwner : TCustomListView; FOwner : TCustomListView;
FItems : TList; FItems : TList;
Function GetCount : Integer; function GetCount : Integer;
procedure ItemDeleted(const AItem: TListItem); //called by TListItem when freed
protected protected
function GetItem(const AIndex: Integer): TListItem; function GetItem(const AIndex: Integer): TListItem;
procedure SetITem(const AIndex: Integer; const AValue: TListItem); procedure SetITem(const AIndex: Integer; const AValue: TListItem);
@ -1782,6 +1783,10 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.29 2002/03/24 16:38:00 lazarus
MWE:
* Fixed bug on ListItems.Delete
Revision 1.28 2002/03/23 15:51:17 lazarus Revision 1.28 2002/03/23 15:51:17 lazarus
MWE: Fixed more compatebility issues (Sort, SelectedItem) MWE: Fixed more compatebility issues (Sort, SelectedItem)

View File

@ -72,7 +72,7 @@ destructor TListItem.Destroy;
begin begin
FDestroying := True; FDestroying := True;
if FOwner <> nil if FOwner <> nil
then FOwner.Delete(Index); then FOwner.ItemDeleted(Self);
SubItems.Free; SubItems.Free;
inherited Destroy; inherited Destroy;
@ -90,6 +90,10 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.8 2002/03/24 16:38:01 lazarus
MWE:
* Fixed bug on ListItems.Delete
Revision 1.7 2002/03/23 15:49:22 lazarus Revision 1.7 2002/03/23 15:49:22 lazarus
MWE: Fixed more compatebility issues (Sort, SelectedItem) MWE: Fixed more compatebility issues (Sort, SelectedItem)

View File

@ -54,10 +54,19 @@ end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
procedure TListItems.Delete(const AIndex: Integer); procedure TListItems.Delete(const AIndex: Integer);
begin begin
if (FItems.Items[Aindex] <> nil) Item[AIndex].Delete;
then Item[AIndex].Delete; end;
FItems.Delete(AIndex);
FOwner.ItemDeleted(AIndex); {------------------------------------------------------------------------------}
{ TListItems ItemDeleted }
{------------------------------------------------------------------------------}
procedure TListItems.ItemDeleted(const AItem: TListItem);
var
idx: Integer;
begin
idx := FItems.Remove(AItem);
if (idx >= 0) and (FOwner <> nil)
then FOwner.ItemDeleted(idx);
end; end;
{------------------------------------------------------------------------------} {------------------------------------------------------------------------------}
@ -111,6 +120,10 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.10 2002/03/24 16:38:01 lazarus
MWE:
* Fixed bug on ListItems.Delete
Revision 1.9 2002/03/23 15:49:22 lazarus Revision 1.9 2002/03/23 15:49:22 lazarus
MWE: Fixed more compatebility issues (Sort, SelectedItem) MWE: Fixed more compatebility issues (Sort, SelectedItem)