Synedit produces an AV on saving files due to issue at left gutter
Original Reporter info from Mantis: aducom
-
Reporter name: albert
Original Reporter info from Mantis: aducom
- Reporter name: albert
Description:
If you save a file from synedit ("myEdit.lines.savetofile(..)") then it calls somewhere "TCustomSynEdit.MarkTextAsSaved;"
The line "if FLeftGutter.Visible and FLeftGutter.ChangesPart(0).Visible then..." generates an error if ChangesPart is nil.
This is possible because routine "function TSynGutterPartListBase.GetByClass(AClass: TSynGutterPartBaseClass; Index: Integer): TSynGutterPartBase; "can evaluate to nil
[code]
function TSynGutterPartListBase.GetByClass(AClass: TSynGutterPartBaseClass; Index: Integer): TSynGutterPartBase;
var
i: Integer;
begin
for i := 0 to Count -1 do
if Part[i] is AClass then begin
if Index = 0 then
exit(Part[i]);
dec(Index);
end;
Result := nil;<================
end;
[/code]
My solution to this problem was a simple test, but not sure to see this as a workaround or fix as I don't know if a nil value should occur or is caused by some other mistake. It works for me ;-)
[code]
procedure TCustomSynEdit.MarkTextAsSaved;
begin
TSynEditStringList(fLines).MarkSaved;
if FLeftGutter.ChangesPart=nil then exit;
if FLeftGutter.Visible and FLeftGutter.ChangesPart(0).Visible then
InvalidateGutter; // Todo: Make the ChangeGutterPart an observer
end;
[/code]
Steps to reproduce:
n.a.
Additional information:
possible workaround/solution in description
Mantis conversion info:
- Mantis ID: 35635
- Build: 60954
- Version: 2.0.2
- Fixed in version: 2.0.4
- Fixed in revision: 61309 (#93d8287c)
- Target version: 2.0.4