[Lazarus] Project Groups are saving LPI files

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Lazarus] Project Groups are saving LPI files

Free Pascal - Lazarus mailing list
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

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Project Groups are saving LPI files

Free Pascal - Lazarus mailing list
On Thu, 15 Aug 2019 13:43:58 +0200
Ondrej Pokorny via lazarus <[hidden email]> 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?


> 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
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Project Groups are saving LPI files

Free Pascal - Lazarus mailing list
On 17.08.2019 16:53, Mattias Gaertner via lazarus wrote:
> On Thu, 15 Aug 2019 13:43:58 +0200
> Ondrej Pokorny via lazarus <[hidden email]> 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

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] Project Groups are saving LPI files

Free Pascal - Lazarus mailing list
On 28.08.2019 09:23, Ondrej Pokorny via lazarus wrote:

> On 17.08.2019 16:53, Mattias Gaertner via lazarus wrote:
>> On Thu, 15 Aug 2019 13:43:58 +0200
>> Ondrej Pokorny via lazarus <[hidden email]> 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
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus