Recent

Author Topic: Where are the sources for the default project that opens when the IDE starts?  (Read 539 times)

flowCRANE

  • Hero Member
  • *****
  • Posts: 914
When I open Lazarus, it shows the default console program sources by default. The problem is that these sources are edited by default, and the changes are not saved (see attachment), so if I want to close the IDE, it asks me to save the changes. Since this default project is not saved on disk, there is no path to it in the code editor status bar, so I can't open the file explorer with its location.

What do I do so that when I start the IDE, it opens this default project, but has no edit history? Where is this default project on disk? How do I change the code for this default project? Thanks in advance for your help.



By the way — I have unchecked the option Open last project and packages at start in the IDE Options window.
« Last Edit: March 22, 2025, 06:44:10 pm by flowCRANE »
Lazarus 3.6 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on a retro-style action/adventure game (pixel art), programming the engine from scratch, using Free Pascal and SDL3.

wp

  • Hero Member
  • *****
  • Posts: 12761
When you compile and run the default project (and did not save it yourself) it is automatically saved in the folder specified in "Tools" > "Options" > "Environment" > "Files" > "Directory for building test projects". So, unless you created a new project there's a good chance that you can find the last version of this test project in this folder.

n7800

  • Sr. Member
  • ****
  • Posts: 284
He is referring to the problem that a newly opened project has edits - look at the gutter of changes in the screenshot. "{$R *.res}" was automatically added. And when closing such a project, the IDE asks about saving, although the user did not change anything.

The good news is that I can confirm this in 3.8, but not in trunk.

flowCRANE

  • Hero Member
  • *****
  • Posts: 914
I checked all locations on the disk and even searched directories for .lps files, but I didn't find any that would cause the default project to be already edited.

Where does the IDE get this edit history from anyway?
Lazarus 3.6 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on a retro-style action/adventure game (pixel art), programming the engine from scratch, using Free Pascal and SDL3.

n7800

  • Sr. Member
  • ****
  • Posts: 284
There is no point in searching for something in the file system, since these are unsaved changes. The IDE automatically adds this when opening a project.

Well, I think I found the reason, I'll write about it now...

flowCRANE

  • Hero Member
  • *****
  • Posts: 914
The IDE makes modifications to this default project on startup for some reason, so the only thing I'd like to know is how to make it not apply these changes. They must be saved somewhere.

Interestingly, I tried to save this default, modified program to disk and compiled it. The IDE still asks me when closing whether to save the changes. What's more — double-clicking the Project1.lpr/Project1.lpi file opens the project in the fresh instance of the IDE, but the IDE still thinks it is not saved to disk and the code editor looks like in the screenshot I've attached (even though I opened it from disk). If I press Ctrl+S, the IDE opens a dialog window to save the project. WTF...

Just in case, this happens in the secondary Lazarus installation. The paths for this IDE installation are correct and do not conflict with the first installation. I installed both instances manually, from the official installers for version 3.6.
Lazarus 3.6 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on a retro-style action/adventure game (pixel art), programming the engine from scratch, using Free Pascal and SDL3.

n7800

  • Sr. Member
  • ****
  • Posts: 284
The good news is that I can confirm this in 3.8, but not in trunk.

It turns out that it does not depend on the version, but is the result of the project option "Use manifest resource (and enable themes)" (on the very first page of the settings). Try toggling it on/off, and when saving the settings you will see how it is added/removed in the code.

The fact that this line appears automatically at startup indicates that you once used the "Set compiler options as default" checkbox (in the corner of the project options window) to save default options for new projects. Despite the name, this checkbox saves not only compiler options, but some others as well.

Unfortunately, the same options template is used for all project types. Therefore, if you uncheck this default checkbox, it will be unchecked in all new graphical projects (and it is usually needed there). There is a separate issue #38106 about this.

So, at the moment I can offer options:
1. "Tolerate" this problem if you have a lot of custom options.
2. Delete the options template, returning to the default options for each project type. It is located in the "projectoptions.xml" file in the user configuration (you can just rename it).
3. Alternatively, you can use the "ProjTemplates" package. Its configuration is much more complicated, but it allows you to prepare not only options, but also any project template files.

To be clear, fixing #38106 won't help if you still want to mark this option for console projects. So please create a new issue on the bug tracker. I can suggest a possible solution there.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 11029
  • Debugger - SynEdit - and more
    • wiki
What's more — double-clicking the Project1.lpr/Project1.lpi file opens the project in the fresh instance of the IDE, but the IDE still thinks it is not saved to disk

Well,.. The following may not apply, if indeed there are changed lines indicated.

The IDE may also ask about saving the project's session (though afaik it will say "session" in the question dlg, if it is only session).
And that question is not on by default (by default session is saved without asking).
And session can be as little as moving the caret in the editor, or switching tabs.

n7800

  • Sr. Member
  • ****
  • Posts: 284
Interestingly, I tried to save this default, modified program to disk and compiled it. The IDE still asks me when closing whether to save the changes.

After compiling the project, did the color of the modified lines in the gutter change to green? The file should be saved automatically when compiling.

What's more — double-clicking the Project1.lpr/Project1.lpi file opens the project in the fresh instance of the IDE, but the IDE still thinks it is not saved to disk and the code editor looks like in the screenshot I've attached (even though I opened it from disk). If I press Ctrl+S, the IDE opens a dialog window to save the project. WTF...

Clarify, did you launch the project in a "new" instance without closing the old one?

flowCRANE

  • Hero Member
  • *****
  • Posts: 914
The IDE may also ask about saving the project's session (though afaik it will say "session" in the question dlg, if it is only session).

I have this option disabled, so the IDE never ask me about saving project's session (I prefer the IDE to do it silently).



After compiling the project, did the color of the modified lines in the gutter change to green? The file should be saved automatically when compiling.

Yes, the color has changed to that of saved changes (according to my code color scheme, it is gray). So the IDE behaves correctly and correctly saves the project to files and updates the code editor content. I recompiled the project additionally, just in case.

Clarify, did you launch the project in a "new" instance without closing the old one?

Yes. To avoid confusion, I first closed all instances of Lazarus.

For the test, I opened the IDE, saved this default project to disk (I left the default file name), compiled it and closed the IDE (the only instance open). Then I opened the directory with the saved project files, double-clicked on the Project1.lpr file, the IDE opened, but instead of loading the project from the clicked file, the IDE showed me the default project and treated it as unsaved — the full file path was not provided in the main IDE window title bar and in the code editor status bar, the file name in the code editor tab was preceded by an asterisk, and there was a visible change in the code (the gutter contained an orange line indicating modified lines).

Then I searched further for problems, changed various IDE settings and this problem disappeared (it is no longer reproducible). However, there is still a problem that a fresh run of Lazarus (including the first instance) creates a default project with modified lines (like I described in the first post).



I'll try changing the IDE settings, including the default project settings. Maybe one of the changes will affect the default project so that it's not modified from the start. Thanks for your help so far!
Lazarus 3.6 with FPC 3.2.2, Windows 10 — all 64-bit

Working solo on a retro-style action/adventure game (pixel art), programming the engine from scratch, using Free Pascal and SDL3.

 

TinyPortal © 2005-2018