Browse Source

debug: 检查树结构完善

JimiZhang 1 week ago
parent
commit
a4323b2640

+ 2 - 2
MainModule/Model/ScBillsDM.pas

@@ -4687,14 +4687,14 @@ var
       begin
         if arrChild[L, 0] = iID then
         begin
-          bFindNext := True;
           iLastID := arrChild[L, 1];
-          SetLength(arrNext, Length(arrNext) + 1);
           if ArrayIndexOf(iLastID, arrNext) > 0 then
           begin
             Result := iID;
             Exit;
           end;
+          bFindNext := True;
+          SetLength(arrNext, Length(arrNext) + 1);
           arrNext[Length(arrNext) - 1] := iLastID;
           Break;
         end;

BIN
Tools/CheckIDTree/CheckIDTree.exe


+ 5 - 2
Tools/CheckIDTree/Unit1.pas

@@ -99,25 +99,28 @@ var
   var
     L, M, iID, iLastID: Integer;
     arrNext: array of Integer;
+    bHasNext: Boolean;
   begin
     Result := -1;
     if Length(arrChild) <= 1 then Exit;
     iLastID := AID;
     repeat
       iID := iLastID;
+      bHasNext := False;
       for L := Low(arrChild) to High(arrChild) do
       begin
         if arrChild[L, 0] = iID then
         begin
           iLastID := arrChild[L, 1];
-          SetLength(arrNext, Length(arrNext) + 1);
           if ArrayIndexOf(iLastID, arrNext) > 0 then
             Exit;
+          bHasNext := True;
+          SetLength(arrNext, Length(arrNext) + 1);
           arrNext[Length(arrNext) - 1] := iLastID;
           Break;
         end;
       end;
-    until (iLastID = AID) or (iLastID = -1);
+    until (iLastID = AID) or (iLastID = -1) or not bHasNext;
     Result := iLastID;
   end;