Lazarus

Programming => LCL => Topic started by: aducom on May 26, 2019, 09:02:09 am

Title: SynEdit produces an error on save file (and fix)
Post by: aducom on May 26, 2019, 09:02:09 am
I have made a bug report that explains that under some circumstances a

Code: Pascal  [Select]
  1. mySynEdit.Lines.SaveToFile

Generates an error. I traced this down to

Code: Pascal  [Select]
  1. procedure TCustomSynEdit.MarkTextAsSaved;
  2. begin
  3.   TSynEditStringList(fLines).MarkSaved;
  4.   if FLeftGutter.Visible and FLeftGutter.ChangesPart(0).Visible then  ...
  5.  

The FLeftGutter.Changespart can be nil under certain circumstances causing an error if you access .visible. I don't know if this situation should occur or is caused by some mishap in my code or somewhere else, but this fix solved it for me:

Code: Pascal  [Select]
  1. procedure TCustomSynEdit.MarkTextAsSaved;
  2. begin
  3.   TSynEditStringList(fLines).MarkSaved;
  4.   if FLeftGutter.ChangesPart=nil then exit;
  5.   if FLeftGutter.Visible and FLeftGutter.ChangesPart(0).Visible then    
  6.  
Title: Re: SynEdit produces an error on save file (and fix)
Post by: lucamar on May 26, 2019, 09:31:38 am
A link to the bug report  would be nice ... O:-)
Title: Re: SynEdit produces an error on save file (and fix)
Post by: aducom on May 26, 2019, 09:56:36 am
https://bugs.freepascal.org/view.php?id=35635
Title: Re: SynEdit produces an error on save file (and fix)
Post by: jamie on May 26, 2019, 07:55:50 pm
It works fine for me when dropping an SynEdit in the form via OI. All parts are there.
are you doing something to remove these parts?
Title: Re: SynEdit produces an error on save file (and fix)
Post by: aducom on May 27, 2019, 10:03:54 pm
No, but I ported my code from 32 to 64 bits and upgraded lazarus. I think something must have gone wrong. I managed by adding the missing parts in the lfm file. However, there is an issue because you can remove a part, but you are not able to add it again because you can only add line number part. But that's another issue ;-) A tiny bit of hacking and the issue was solved.