Recent

Author Topic: Lazarus IDE problem?  (Read 611 times)

ad1mt

  • Sr. Member
  • ****
  • Posts: 477
    • Mark Taylor's Home Page
Lazarus IDE problem?
« on: December 02, 2025, 08:48:01 am »
I just had a problem with the Lazarus IDE.
I was in the early stages of designing a new GUI app.
The first thing I did was rename the default unit1.pas file to main.pas
While working on the main form, I switched away to a web browser to look something up, then I switched back to Lazarus.
When I switched back, I got a warning about the main.pas file having been changed by another app/program!
I didn't understand why I was getting this, and I clicked the "Reload from disk" button without thinking, and lost all the work I had done.
Something is wrong somewhere.
Am I allowed to rename the default unit1.pas file at the very start of a new project? Was this the cause of the problem?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11900
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus IDE problem?
« Reply #1 on: December 02, 2025, 09:43:22 am »
I don't know what caused it.

If you have a new project, it will create a file in the temp folder. That gets saved whenever you compile it. => so (some of) your project may still be there. Depending on if it went under the new name or old name, and if you had another new project that overwrote it.

There also should be backup folder in your temp dir, and again, depending on how much (on new projects) you have done since, it may have some of the files.

ad1mt

  • Sr. Member
  • ****
  • Posts: 477
    • Mark Taylor's Home Page
Re: Lazarus IDE problem?
« Reply #2 on: December 02, 2025, 10:11:16 am »
@Martin_fr 
Thanks for your reply.
Am I allowed to rename the uni1.pas file to main.pas?  This appeared to work ok, but could that be a possible cause?

dbannon

  • Hero Member
  • *****
  • Posts: 3607
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Lazarus IDE problem?
« Reply #3 on: December 02, 2025, 10:12:44 am »
Am I allowed to rename the default unit1.pas file at the very start of a new project? Was this the cause of the problem?

Renaming from with in the IDE using SaveAs ?  Yep.  Using, eg your file manager or the command line, nope ! (unless yo delve down into the project and lfm file too, not a good idea.)

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Thaddy

  • Hero Member
  • *****
  • Posts: 18483
  • Here stood a man who saw the Elbe and jumped it.
Re: Lazarus IDE problem?
« Reply #4 on: December 02, 2025, 12:12:38 pm »
I ran into the same issue, where I needed to edit just the lpr to rename a not-existing unit1 to its real new name.
This is 100%  reproducable.
I just forgot to mention it, but it happens all the time: I got used to it.
If you just rename the unit and save that, the project file does not follow and still only knows ... unit1.
Delphi does not have this synchronizing problem.
« Last Edit: December 02, 2025, 12:18:14 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

ad1mt

  • Sr. Member
  • ****
  • Posts: 477
    • Mark Taylor's Home Page
Re: Lazarus IDE problem?
« Reply #5 on: December 02, 2025, 12:17:56 pm »
I have also reproduced the problem.
I started the app project again, this time leaving the unit1.pas file name unchanged.
I made a backup of the project foldir (just in case!).
I renamed the unit1.pas file to main.pas, and soon after, the IDE gave me the "files have changed in disk" warning.
I clicked the "ignore changes" button, and Lazarus carried on correctly.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11900
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus IDE problem?
« Reply #6 on: December 02, 2025, 12:22:54 pm »
I have also reproduced the problem.
I started the app project again, this time leaving the unit1.pas file name unchanged.
I made a backup of the project foldir (just in case!).
I renamed the unit1.pas file to main.pas, and soon after, the IDE gave me the "files have changed in disk" warning.
I clicked the "ignore changes" button, and Lazarus carried on correctly.

Then please report on the bug tracker.

Thaddy

  • Hero Member
  • *****
  • Posts: 18483
  • Here stood a man who saw the Elbe and jumped it.
Re: Lazarus IDE problem?
« Reply #7 on: December 02, 2025, 12:31:22 pm »
The description would be that:
In an open project, when a unit is renamed, the lpr file is not parsed and updated as well.
Other unit dependencies are OK and updated, it seems. Just not the project file. the lpr.

I will run some tests for the above. The lpr part is 100% true in all cases.
« Last Edit: December 02, 2025, 12:37:03 pm by Thaddy »
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.

n7800

  • Hero Member
  • *****
  • Posts: 583
  • Lazarus IDE contributor
    • GitLab profile
Re: Lazarus IDE problem?
« Reply #8 on: December 04, 2025, 08:20:31 am »
I still don't see any clear indication of how the file was renamed - through the IDE menu or directly in the folder using the file manager? And was the IDE open at the time?

@Thaddy, I'm not sure you and the thread starter are talking about the same thing...

And please both clarify your Lazarus version. There were many changes to the identifier/file renaming function in trunk.

BrunoK

  • Hero Member
  • *****
  • Posts: 747
  • Retired programmer
Re: Lazarus IDE problem?
« Reply #9 on: December 04, 2025, 10:16:30 am »
Win10, lazarus trunk, Fpc 3.2.2

1 - Project / New project ... / Application

2 - Run the application with the empty form, all is well

3 - Project / Save project
 a: Project name -> prjTopic_72901
 b: Save unit1 name -> frmTopic_72901

4 - Run this newly named project
 -> prjTopic_72901.lpr(13,10) Error: Cannot find Unit1 used by prjTopic_72901 of the Project Inspector.

wp

  • Hero Member
  • *****
  • Posts: 13264
Re: Lazarus IDE problem?
« Reply #10 on: December 04, 2025, 11:57:09 am »
How old is your trunk? I cannot reproduce this issue with the current trunk on Win 11. I remember that I had reported this issue several months ago, and it was fixed afterwards - however I still see similar issues from time to time which I have not been able to reproduce.

BrunoK

  • Hero Member
  • *****
  • Posts: 747
  • Retired programmer
Re: Lazarus IDE problem?
« Reply #11 on: December 04, 2025, 12:31:53 pm »
Lazarus 4.99 (rev 4.99) FPC 3.2.2 x86_64-win64-win32/win64

Yesterday trunk

Git gives last revision in my repository :
Revision: c213639172fc2ca508bd86f56b4777ad95d4ff68
Author: Martin <laz.git@mfriebe.de>
Date: 03.12.2025 10:53:08
Message:
SynEdit: implement OwnObjects and OnBeforeDeleteLines. Issue #41768

----
Added: components/synedit/docs/xml/syneditlines.xml




wp

  • Hero Member
  • *****
  • Posts: 13264
Re: Lazarus IDE problem?
« Reply #12 on: December 04, 2025, 12:35:58 pm »
What did you do before step 1? What happens when you start the IDE and execute your steps with the default project of the new IDE? That's what I did.

BrunoK

  • Hero Member
  • *****
  • Posts: 747
  • Retired programmer
Re: Lazarus IDE problem?
« Reply #13 on: December 04, 2025, 12:51:59 pm »
What did you do before step 1? What happens when you start the IDE and execute your steps with the default project of the new IDE? That's what I did.

I managed once to have it correctly written even with a unit1 name change, probably just after starting lazarus.

But creating a new empty application -> run -> save project with unit1 saved as unit2 reproduced exactly what I described above.

wp

  • Hero Member
  • *****
  • Posts: 13264
Re: Lazarus IDE problem?
« Reply #14 on: December 04, 2025, 03:00:17 pm »
These are my steps:
- Windows 11, 64-bit IDE (Laz/main + fpc 3.2.2)
- Update IDE from git, clean rebuild of the IDE ("Normal IDE")
- Load one of my project, compile & run

1st test
- Create new empty project
- Compile & run
- Save project under a new name (i.e. test.lpi, utest.pas) in some new (empty) folder
- Compile & run -- no problem.

2nd test
- Create new project
- Compile & run
- Save as test_project and test_unit in the same folder that I had used for the first project
- Compile & run -- no problem

3rd test
- Create new project
- Compile & run
- Save unit1 as unit2 and project1 unchanged in the same folder
- Compile & run -- no problem

What am I missing?

 

TinyPortal © 2005-2018