Sign in Join

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

Mailing lists / lazarus / 2021-05

Lazarus created an lfm form file from the dfm but uses both causing confusion...

2 messages · 1 person · –

Reply by email Subscribe to this list Your subscription

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

Bo Berglund

So I have a project with a few forms. It is maintained in SVN and both pas and dfm files are in SVN.
I have ported the project from Delphi so I have these pas/dfm files.

This week I have modified form layouts by moving stuff around and changing properties etc. For some reason Lazarus then created lfm form files where the new layout can be seen. In fact Lazarus uses the lfm files in the IDE... I did not notice thta tyhis had happened.

Today I had an accident that deleted the code folder completely except for some remaining files from which I have reconstructed the project using the last SVN commit and the weekly backup of my PC taken Saturday night too. Since the commit did not include the lfm files (I was not aware of their existence) they are not in SVN, but they are in a leftover folder (I cannot say why it was left there...)

Now I have both dfm and lfm form files in the project folder and it seems like Lazarus is using the lfm files because I can see my changed layout in Lazarus. But when I build the project the result is the old layout still.

When I discovered the extra lfm files I renamed the dfm to dfm.bak and then tried to build the project.
But now it throws up an error complaining that it cannot find the dfm file, which it has replaced by an lfm file all by itself...

How can I restore order here and tell Lazarus to use the lfm files, which its editor does but not when Lazarus is building the project. At that time it looks for the dfm file instead.
In Lazarus I can switch betweeen code and form view and then I see the lfm view.

Lazarus 2.0.12, FPC 3.2.0 on Windows 10

Bo Berglund Developer in Sweden

Reply by email

Bo Berglund
to Bo Berglund

On Fri, 07 May 2021 02:14:36 +0200, Bo Berglund via lazarus wrote:

UPDATE:
I managed to clear up the mess and found some interesting things in the process...

This week I have modified form layouts by moving stuff around and changing properties etc. For some reason Lazarus then created lfm form files where the new layout can be seen. In fact Lazarus uses the lfm files in the IDE... I did not notice that this had happened.

In fact this was NOT what had happened! The files were still dfm files up until the "delete accident" happened! I just assumed this was what had happened.

Today I had an accident that deleted the code folder completely except for some remaining files from which I have reconstructed the project using the last SVN commit and the weekly backup of my PC taken Saturday night too.

In addition to the SVN commit and the backup done earlier I also had this "mysterious" client folder contaiining actual source files all with a file date about the time of the accidental delete.
And here all form files had extension lfm.

Yesterday while driving I realized what must have happened is this:
- At the time of the accidental delete Lazarus was running and had a dozen or more source files open in the code editor.
- When the source dir suddenly disappeared Lazarus noted this
- When I saw that Lazarus was running I thought this was not a good idea so I tried shutting it down
- This caused Lazarus to pop up a lot of error messages, which I clicked away until done.
- The error messages were popped up because Lazarus apparently had lost connection to the files on disk and it tried to solve the situation.

The end result of this was that Lazarus *saved* the contrent of all the sources it had open to the path they were read from, recreating the missing folders in the process!
And since there were no dfm files to overwrite it saved the forms in native Lazarus format as lfm files.

So the folder I found is actually *all* of the sources in the editor as they were when the crash happened!

When I then could reach my computer I tested by:
1) Renaming all lfm files to dfm extension in the "save" directory
2) Copying the content of this directory to the newly checked out project overwriting all existing files
3) Now started Lazarus.

At this point the project auto-loaded again and when I ran a build it succeeded and the binary looked exactly like it did before all this happened! :)

So I was saved by Lazarus! It would not let the loaded files disappear!

Bo Berglund Developer in Sweden

Reply by email