Some random server versions have duplicated category names in help tables, which cause infinite tree recursion in help tree, e.g. for "Polygon properties" > "Contents". Do not display these duplicates as folder to avoid infinite recursion. Fixes issue #2135.

This commit is contained in:
Ansgar Becker
2010-08-26 00:02:10 +00:00
parent 961f7f0f3f
commit a64b9412ef

View File

@ -214,20 +214,34 @@ procedure TfrmSQLhelp.treeTopicsInitNode(Sender: TBaseVirtualTree; ParentNode,
Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates); Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
var var
Results: TMySQLQuery; Results: TMySQLQuery;
Folder: String; ThisFolder, PrevFolder: String;
N: PVirtualNode;
VT: TVirtualStringTree;
RecursionAlarm: Boolean;
begin begin
// Display plus button for nodes which are folders // Display plus button for nodes which are folders
VT := Sender as TVirtualStringTree;
Results := GetHelpResult(Node); Results := GetHelpResult(Node);
Results.RecNo := Node.Index; Results.RecNo := Node.Index;
Folder := ''; if Results.Col('is_it_category', True) = 'Y' then begin
if Assigned(ParentNode) then // Some random server versions have duplicated category names in help tables, which would cause
Folder := treeTopics.Text[ParentNode, treeTopics.Header.MainColumn]; // infinite tree recursion, e.g. for "Polygon properties" > "Contents". Do not display these
if Results.ColExists('is_it_category') // duplicates as folder
and (Results.Col('is_it_category') = 'Y') RecursionAlarm := False;
and (Results.Col('name') <> Folder) ThisFolder := Results.Col('name');
then N := VT.GetPreviousInitialized(Node);
while Assigned(N) do begin
PrevFolder := VT.Text[N, VT.Header.MainColumn];
if VT.HasChildren[N] and ((ThisFolder=PrevFolder) or (ThisFolder='Contents')) then begin
RecursionAlarm := True;
break;
end;
N := VT.GetPreviousInitialized(N);
end;
if not RecursionAlarm then
Include(InitialStates, ivsHasChildren); Include(InitialStates, ivsHasChildren);
end; end;
end;
procedure TfrmSQLhelp.ButtonCloseClick(Sender: TObject); procedure TfrmSQLhelp.ButtonCloseClick(Sender: TObject);