Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when editing trackers with pre-rpc-17 Transmission #71

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ TMainForm = class(TBaseForm)
procedure OnThemeChanged;
function CommentIsLink: Boolean;
function ArgsToTrackerList(torrentObj: TJSONObject) : TStringList;
procedure TrackerListToArgs(torrentSetArgs: TJSONObject; trackerEditField: TMemo);
procedure TrackerListToArgs(parsedTrackers: TStringList; torrentSetArgs: TJSONObject; trackerEditField: TMemo);
public
procedure FillTorrentsList(list: TJSONArray);
procedure FillPeersList(list: TJSONArray);
Expand Down Expand Up @@ -3786,15 +3786,14 @@ function TMainForm.ArgsToTrackerList(torrentObj: TJSONObject) : TStringList;
Result:=trlist;
end;

procedure TMainForm.TrackerListToArgs(torrentSetArgs: TJSONObject; trackerEditField: TMemo);
procedure TMainForm.TrackerListToArgs(parsedTrackers: TStringList; torrentSetArgs: TJSONObject; trackerEditField: TMemo);
var
AddT, EditT, DelT: TJSONArray;
sl, trlist: TStringList;
sl: TStringList;
i, j: integer;
s: string;
begin
if RpcObj.ShouldUseTrackerList then begin
writeln(trackerEditField.Text);
torrentSetArgs.Add('trackerList', trackerEditField.Text);
end
else begin
Expand All @@ -3809,9 +3808,9 @@ procedure TMainForm.TrackerListToArgs(torrentSetArgs: TJSONObject; trackerEditFi
sl.Delete(i);
continue;
end;
j:=trlist.IndexOf(s);
j:=parsedTrackers.IndexOf(s);
if j >= 0 then begin
trlist.Delete(j);
parsedTrackers.Delete(j);
sl.Delete(i);
continue;
end;
Expand All @@ -3824,17 +3823,17 @@ procedure TMainForm.TrackerListToArgs(torrentSetArgs: TJSONObject; trackerEditFi
try
for i:=0 to sl.Count - 1 do begin
s:=Trim(sl[i]);
if trlist.Count > 0 then begin
EditT.Add(PtrUInt(trlist.Objects[0]));
if parsedTrackers.Count > 0 then begin
EditT.Add(PtrUInt(parsedTrackers.Objects[0]));
EditT.Add(UTF8Decode(s));
trlist.Delete(0);
parsedTrackers.Delete(0);
end
else
AddT.Add(UTF8Decode(s));
end;

for i:=0 to trlist.Count - 1 do
DelT.Add(PtrUInt(trlist.Objects[i]));
for i:=0 to parsedTrackers.Count - 1 do
DelT.Add(PtrUInt(parsedTrackers.Objects[i]));

if AddT.Count > 0 then begin
torrentSetArgs.Add('trackerAdd', AddT);
Expand Down Expand Up @@ -4041,7 +4040,7 @@ procedure TMainForm.TorrentProps(PageNo: integer);
if cbIdleSeedLimit.State = cbChecked then
args.Add('seedIdleLimit', edIdleSeedLimit.Value);

TrackerListToArgs(args, edTrackers);
TrackerListToArgs(trlist, args, edTrackers);
end;

args.Add('peer-limit', edPeerLimit.Value);
Expand Down