Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2019-08

Project Groups are saving LPI files

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ondrej Pokorny

Hello (Mattias)!

Project groups are saving my LPI files upon loading the project group. This is a problem because they resave LPIs without BOM and then all LPIs are marked as modified in SVN because they were saved with BOM. (Lazarus IDE saves my project files with BOM.)

I searched the reason and found out that TXMLConfig is the problem. There are 2 issues:

1.) TXMLConfig should keep the original encoding along with BOM. 2.) Project groups should never save LPIs.

About 2.:
The problem is:
constructor TXMLConfig.CreateClean(const AFilename: String);
begin
   //DebugLn(['TXMLConfig.CreateClean ',AFilename]);
   fDoNotLoadFromFile:=true;
   Create(AFilename);
   FModified:=FileExistsCached(AFilename);
end;

FModified gets True here - why? Is there a reason why the config should be set as Modified on create and consequently be resaved on Free when FileExistsCached returns true?

Setting the Modified flag to False in TIDECompileTarget.LoadProject before xml.Free is definitely a fix but IMO it should be fixed within TXMLConfig.

---
The above code could be a cause for another problem as well - when the currently open LPI project file is modified externally (e.g. SVN update), Lazarus IDE asks to reload the project but sometimes the LPI file is rewritten by the IDE and the new external changes get lost. I experienced this issue before installing Project groups but could not find clear steps-to-reproduce and could not find the reason for it.

Ondrej

Reply by email

Mattias Gaertner
to Ondrej Pokorny
[...] Project groups are saving my LPI files upon loading the project group.

Huh? Do you really mean, merely opening a lpg touches some lpi files?

Show quoted text 23 lines
This is a problem because they resave LPIs without BOM and then all LPIs are marked as modified in SVN because they were saved with BOM. (Lazarus IDE saves my project files with BOM.) I searched the reason and found out that TXMLConfig is the problem. There are 2 issues: 1.) TXMLConfig should keep the original encoding along with BOM. 2.) Project groups should never save LPIs. About 2.: The problem is: constructor TXMLConfig.CreateClean(const AFilename: String); begin   //DebugLn(['TXMLConfig.CreateClean ',AFilename]);   fDoNotLoadFromFile:=true;   Create(AFilename);   FModified:=FileExistsCached(AFilename); end; FModified gets True here - why? Is there a reason why the config should be set as Modified on create and consequently be resaved on Free when FileExistsCached returns true?
TXMLConfig.CreateClean;
TXMLConfig.Flush; -> should write, so needs Modified=true

Maybe it is a bad idea to auto flush on Destroy.

Mattias

Reply by email

Ondrej Pokorny
to Mattias Gaertner
Mattias Gaertner wrote 7 lines
On Thu, 15 Aug 2019 13:43:58 +0200 Ondrej Pokorny via lazarus wrote: > [...] > Project groups are saving my LPI files upon loading the project > group. Huh? Do you really mean, merely opening a lpg touches some lpi files?

Yes, this is exactly what happens. The project group rewrites all lpi files within the project group itself.

TXMLConfig.CreateClean; TXMLConfig.Flush; -> should write, so needs Modified=true Maybe it is a bad idea to auto flush on Destroy.

So what is the reason to have the modified flag when it is set to true on loading - when the file is definitely not modified?

Another idea would be to have a "Force: Boolean" parameter in Flush that would ignore the modified flag and write anyway.

Ondrej

Reply by email

Ondrej Pokorny
to Ondrej Pokorny
Ondrej Pokorny wrote 11 lines
On 17.08.2019 16:53, Mattias Gaertner via lazarus wrote: > On Thu, 15 Aug 2019 13:43:58 +0200 > Ondrej Pokorny via lazarus wrote: > >> [...] >> Project groups are saving my LPI files upon loading the project >> group. > Huh? Do you really mean, merely opening a lpg touches some lpi files? Yes, this is exactly what happens. The project group rewrites all lpi files within the project group itself.

I reported it: https://bugs.freepascal.org/view.php?id=36030

Ondrej

Reply by email