LCL: Fix TreeView "nothing selected" index. Return -1 instead of crash. For Delphi compatibility. Issue #27759, patch from Ocean.

git-svn-id: trunk@48556 -
This commit is contained in:
juha 2015-03-31 17:10:39 +00:00
parent 384c407672
commit f641bb7c5d

View File

@ -1135,10 +1135,10 @@ function TTreeNode.GetIndex: Integer;
var
ANode: TTreeNode;
begin
if FIndex>=0 then begin
Result:=FIndex;
exit;
end;
if self = nil then
exit(-1);
if FIndex>=0 then
exit(FIndex);
// many algorithms uses the last sibling, so we check that first for speed
if (Parent<>nil) and (Parent[Parent.Count-1]=Self) then begin
Result:=Parent.Count-1;