View Issue Details

IDProjectCategoryView StatusLast Update
0035635LazarusOtherpublic2019-06-01 13:29
ReporteralbertAssigned ToMartin Friebe 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version2.0.2Product Build60954 
Target VersionFixed in Version2.0.4 
Summary0035635: Synedit produces an AV on saving files due to issue at left gutter
DescriptionIf 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 Reproducen.a.
Additional Informationpossible workaround/solution in description
TagsNo tags attached.
Fixed in Revision61309
LazTarget2.0.4
WidgetsetWin32/Win64
Attached Files

Activities

Martin Friebe

2019-06-01 13:29

manager   ~0116517

Please test and close if ok

Issue History

Date Modified Username Field Change
2019-05-26 08:54 albert New Issue
2019-05-26 11:58 Bart Broersma Assigned To => Martin Friebe
2019-05-26 11:58 Bart Broersma Status new => assigned
2019-06-01 13:29 Martin Friebe Status assigned => resolved
2019-06-01 13:29 Martin Friebe Resolution open => fixed
2019-06-01 13:29 Martin Friebe Fixed in Version => 2.0.4
2019-06-01 13:29 Martin Friebe Fixed in Revision => 61309
2019-06-01 13:29 Martin Friebe LazTarget => 2.0.4
2019-06-01 13:29 Martin Friebe Widgetset Win32/Win64 => Win32/Win64
2019-06-01 13:29 Martin Friebe Note Added: 0116517