LCL, TreeView: Assertion + other minor changes

git-svn-id: trunk@35297 -
This commit is contained in:
juha 2012-02-10 20:30:03 +00:00
parent f37d2be89d
commit 5e1c1bbb19

View File

@ -249,8 +249,7 @@ begin
end; end;
end; end;
procedure TTreeNodeExpandedState.Apply(FirstTreeNode: TTreeNode; procedure TTreeNodeExpandedState.Apply(FirstTreeNode: TTreeNode; CollapseToo: boolean);
CollapseToo: boolean);
var var
ChildNode: TTreeNode; ChildNode: TTreeNode;
ANode: TAvgLvlTreeNode; ANode: TAvgLvlTreeNode;
@ -271,8 +270,7 @@ begin
end; end;
end; end;
procedure TTreeNodeExpandedState.Apply(TreeView: TCustomTreeView; procedure TTreeNodeExpandedState.Apply(TreeView: TCustomTreeView; CollapseToo: boolean);
CollapseToo: boolean);
begin begin
Apply(TreeView.Items.GetFirstNode,CollapseToo); Apply(TreeView.Items.GetFirstNode,CollapseToo);
end; end;
@ -894,8 +892,8 @@ begin
repeat repeat
Result := Result.GetNextSibling; Result := Result.GetNextSibling;
until ((Result=nil) or (Result.FVisible)); until ((Result=nil) or (Result.FVisible));
if (Result<>nil) and (not Result.FVisible) then if (Result<>nil) and (not Result.FVisible) then // Result := nil ... will be removed
Result := nil Assert(False,'TTreeNode.GetNextVisibleSibling: (Result<>nil) and (not Result.FVisible)');
end; end;
function TTreeNode.GetPrevVisible: TTreeNode; function TTreeNode.GetPrevVisible: TTreeNode;
@ -914,8 +912,7 @@ begin
Assert(Parent.Visible, 'TTreeNode.GetPrevVisible: Parent is not Visible'); Assert(Parent.Visible, 'TTreeNode.GetPrevVisible: Parent is not Visible');
Result := Parent; Result := Parent;
end; end;
if (Result<>nil) and (TreeView<>nil) and (not TreeView.IsNodeVisible(Result)) if (Result<>nil) and (TreeView<>nil) and (not TreeView.IsNodeVisible(Result)) then
then
Result:=nil; Result:=nil;
end; end;
@ -925,8 +922,8 @@ begin
repeat repeat
Result := Result.GetPrevSibling; Result := Result.GetPrevSibling;
until ((Result=nil) or (Result.FVisible)); until ((Result=nil) or (Result.FVisible));
if (Result<>nil) and (not Result.FVisible) then if (Result<>nil) and (not Result.FVisible) then // Result := nil ... will be removed
Result := nil Assert(False,'TTreeNode.GetPrevVisibleSibling: (Result<>nil) and (not Result.FVisible)');
end; end;
function TTreeNode.GetPrevExpanded: TTreeNode; function TTreeNode.GetPrevExpanded: TTreeNode;
@ -1027,8 +1024,10 @@ begin
if Assigned(Result) and not Result.Visible then begin if Assigned(Result) and not Result.Visible then begin
Result := Result.GetPrevVisible; Result := Result.GetPrevVisible;
// ToDo: implement this better. Now it works only when Self is visible. // ToDo: implement this better. Now it works only when Self is visible.
if Result = Self then // No visible nodes found. if Result = Self then begin // No visible nodes found.
Assert(Visible, 'TTreeNode.GetLastVisibleChild: Node is not Visible');
Result := Nil; Result := Nil;
end;
end; end;
end; end;
@ -3465,7 +3464,7 @@ procedure TCustomTreeView.UpdateBottomItem;
begin begin
if (FStates*[tvsTopItemNeedsUpdate,tvsTopsNeedsUpdate,tvsBottomItemNeedsUpdate]=[]) if (FStates*[tvsTopItemNeedsUpdate,tvsTopsNeedsUpdate,tvsBottomItemNeedsUpdate]=[])
then exit; then exit;
if not (tvsBottomItemNeedsUpdate in FStates) then exit; // if not (tvsBottomItemNeedsUpdate in FStates) then exit; already above
FBottomItem:=TopItem; FBottomItem:=TopItem;
while (FBottomItem<>nil) and (FBottomItem.GetNextVisible<>nil) do while (FBottomItem<>nil) and (FBottomItem.GetNextVisible<>nil) do
FBottomItem:=FBottomItem.GetNextVisible; FBottomItem:=FBottomItem.GetNextVisible;