OSDN Git Service

巡回の削除の不具合の修正
[gikonavigoeson/gikonavi.git] / RoundData.pas
index b4f2313..3c6373e 100644 (file)
@@ -175,12 +175,12 @@ procedure TRoundList.Clear;
 var
        i: Integer;
 begin
-       for i := 0 to FBoardList.Count - 1 do begin
+       for i := FBoardList.Count - 1 downto 0 do begin
         if FBoardList[i] <> nil then
                        TRoundItem(FBoardList[i]).Free;
                FBoardList.Delete(i);
        end;
-       for i := 0 to FItemList.Count - 1 do begin
+       for i := FItemList.Count - 1 downto 0 do begin
         if FItemList[i] <> nil then
                        TRoundItem(FItemList[i]).Free;
                FItemList.Delete(i);
@@ -224,14 +224,25 @@ var
        Item: TRoundItem;
 begin
        Result := -1;
-       for i := 0 to FItemList.Count - 1 do begin
-               Item := TRoundItem(FItemList[i]);
-               if Item.FRoundType <> RoundType then Continue;
-               if Item.FURL = URL then begin
-                       Result := i;
-                       Exit;
+    if RoundType = grtItem then begin
+               for i := 0 to FItemList.Count - 1 do begin
+                       Item := TRoundItem(FItemList[i]);
+                       if Item.FRoundType <> RoundType then Continue;
+                       if Item.FURL = URL then begin
+                               Result := i;
+                               Exit;
+                       end;
                end;
-       end;
+    end else begin
+        for i := 0 to FBoardList.Count - 1 do begin
+                       Item := TRoundItem(FBoardList[i]);
+                       if Item.FRoundType <> RoundType then Continue;
+                       if Item.FURL = URL then begin
+                               Result := i;
+                               Exit;
+                       end;
+               end;
+    end;
 end;
 procedure TRoundList.Delete(URL: string; RoundType: TGikoRoundType);
 var
@@ -242,17 +253,26 @@ var
 begin
        idx := Find(URL, RoundType);
        if idx <> -1 then begin
-               Item := TRoundItem(FItemList[idx]);
-               Item.Free;
-               FItemList.Delete(idx);
+
         if RoundType = grtBoard then begin
+                       Item := TRoundItem(FBoardList[idx]);
+                       Item.Free;
+                       FBoardList.Delete(idx);
                board := BBSsFindBoardFromURL(URL);
-            board.Round := False;
-            board.RoundName := '';
+            if board <> nil then begin
+               board.Round := False;
+               board.RoundName := '';
+            end;
         end else begin
+                       Item := TRoundItem(FItemList[idx]);
+                       Item.Free;
+                       FItemList.Delete(idx);
+
             threadItem := BBSsFindThreadFromURL(URL);
-            threadItem.Round := false;
-            threadItem.RoundName := '';
+            if threadItem <> nil then begin
+                   threadItem.Round := false;
+               threadItem.RoundName := '';
+            end;
         end;
        end;
 end;