Implements freeing the accessibility object of individual TTreeView items

git-svn-id: trunk@34891 -
This commit is contained in:
sekelsenmat 2012-01-24 08:04:18 +00:00
parent 2fb60ec76d
commit 371b050768
2 changed files with 19 additions and 1 deletions

View File

@ -165,9 +165,16 @@ end;
procedure TLazAccessibleObject.RemoveChildAccessibleObject(
AObject: TLazAccessibleObject);
var
lIndex: Integer;
begin
if FChildren = nil then Exit;
FChildren.Remove(@AObject);
lIndex := FChildren.IndexOf(AObject);
if lIndex >= 0 then
begin
TLazAccessibleObject(FChildren.Items[lIndex]).Free;
FChildren.Delete(lIndex);
end;
end;
function TLazAccessibleObject.GetChildAccessibleObject(AIndex: Integer): TLazAccessibleObject;

View File

@ -305,6 +305,8 @@ begin
end;
destructor TTreeNode.Destroy;
var
lOwnerAccessibleObject, lAccessibleObject: TLazAccessibleObject;
begin
{$IFDEF TREEVIEW_DEBUG}
DebugLn('[TTreeNode.Destroy] Self=',DbgS(Self),' Self.Text=',Text);
@ -316,6 +318,15 @@ begin
if Assigned(Owner) and Assigned(Owner.Owner) then
Owner.Owner.Delete(Self);
// Remove the accessibility object too
if Assigned(Owner) and Assigned(Owner.Owner) then
begin
lOwnerAccessibleObject := Owner.Owner.GetAccessibleObject();
lAccessibleObject := lOwnerAccessibleObject.GetChildAccessibleObjectWithDataObject(Self);
if lAccessibleObject <> nil then
lOwnerAccessibleObject.RemoveChildAccessibleObject(lAccessibleObject);
end;
// delete children
HasChildren := false;
// unbind all references