Recent

Author Topic: Lazarus not restoring project editor state when loading LPI (SOLVED)  (Read 1793 times)

QuinnMartin

  • New Member
  • *
  • Posts: 28
I searched for this but could not find an answer.

When I load a project that I've been working on, the saved state of the design (Source Editor window, opened units in the various tabs, form being designed, etc) never loads.  The Source Editor never even appears, though I see the project name in the Lazarus window caption.  I have to open all the units and forms again manually one by one, every time.

I do see an LPS file was created and it is writing a new timestamp when I save the project, but apparently Lazarus isn't doing anything with it when loading it.  Project Options > Sessions has "Save in LPS file in project directory" and all of the Save checkboxes checked except for "Save editor info only for project files".  I am using Lazarus IDE V2.0.12.

EDIT: Marked it as solved.
« Last Edit: February 25, 2024, 04:16:15 pm by QuinnMartin »

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: Lazarus not restoring project editor state when loading LPI
« Reply #1 on: February 24, 2024, 11:12:21 pm »
Any/every project, or just 1 specific project?

Bart

TRon

  • Hero Member
  • *****
  • Posts: 2518
Re: Lazarus not restoring project editor state when loading LPI
« Reply #2 on: February 24, 2024, 11:26:58 pm »
@Bart:
Though i can't recall that it was that bad, note the Lazarus version number.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9874
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus not restoring project editor state when loading LPI
« Reply #3 on: February 24, 2024, 11:58:43 pm »
Linux, Windows, Mac?

Anyway, it is likely some data in the session can't be read => if so, the only way to get it working is either:
- avoid getting such data into the session
- Upgrade to a newer version (on that old version, only very generic assistance can be given)


Run your IDE as
Code: Text  [Select][+][-]
  1. lazarus.exe --debug-log=c:\mylog.txt
Then check for error messages, and stack traces in that log.

One think I do remember that would fail loading (at least some parts of the session) was that specific entries in the "watches" window , would not load correctly... But it is ages ago, so I don't recall exactly what values, nor if 2.0.12 was affected.
-- EDIT: actually, it was a breakpoint, specifically if you had address based breakpoints in the ASM window.


As an alternative approach to the --debug-log, you can open  the lps file in an editor.  Remove individual sections (such that the XML remains valid), until the IDE loads the remainder. Then you know which part does not load.
(Note, it may also be a part of the lpi file...)
« Last Edit: February 25, 2024, 12:25:40 am by Martin_fr »

QuinnMartin

  • New Member
  • *
  • Posts: 28
Re: Lazarus not restoring project editor state when loading LPI
« Reply #4 on: February 25, 2024, 01:15:00 am »
Thanks, I like the great support here.

The Lazarus type is Windows.  I wasn't aware we were up to V3.0 already so I did an upgrade to V3.0.  I am getting the same exact problem.

Description of error:
- Set up my IDE as if I am programming, have various units and forms open
- File > Save All
- File > Close All
- File > Open > (select LPI) and in the popup pick "Open Project"
- Project comes up but is empty in the IDE and I have to manually re-open units and forms.

I tried my other projects in V3.0 and they all have the the same issues, they come up completely empty, even if I close, add the forms and units, and open them again.  I don't have any add-ons.  In fact when I upgraded to V3.0 I uninstalled V2.0.12 and installed V3.0 fresh.  So it is broken out of the box, or possibly some bad settings are associated with all the projects.

Below is the debug log, not much in there.  This is starting Lazarus, loading the project, seeing the empty source editor, then closing Lazarus.

It is odd that it is reporting "Could not find a fpc executable in the PATH" as the project compiles fine and it seems like it's the installer's job to sort out where fpc is, not mine.  I got the installer from: https://sourceforge.net/projects/lazarus/files/Lazarus%20Windows%2032%20bits/Lazarus%203.0/lazarus-3.0-fpc-3.2.2-win32.exe/download

Hint: (lazarus) [TMainIDE.ParseCmdLineOptions] PrimaryConfigPath="C:\Users\(MyAcct)\AppData\Local\lazarus"
Hint: (lazarus) [TMainIDE.ParseCmdLineOptions] SecondaryConfigPath="C:\lazarus"
InitializeFppkg failed: Could not find a fpc executable in the PATH
Hint: (lazarus) [TMainIDE.DoOpenProjectFile] "C:\code\programs\dateassign\dateproj.lpi"
Hint: (lazarus) [TBuildManager.SetBuildTarget] Old=i386-win32-win32 New=i386-win32-win32 Changed: OS/CPU=True LCL=False
Hint: (lazarus) [TMainIDE.DoOpenProjectFile] "C:\code\programs\dateassign\dateproj.lpi"
LAZARUS END - cleaning up ...
FreeFormEditor: FormEditor1=TFormEditor
Hint: (lazarus) [TMainIDE.Destroy] B  -> inherited Destroy... TMainIDE
Hint: (lazarus) [TMainIDE.Destroy] END


JuhaManninen

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4468
  • I like bugs.
Re: Lazarus not restoring project editor state when loading LPI
« Reply #5 on: February 25, 2024, 06:31:32 am »
- File > Close All
Hey, you explicitly closed everything!   %)
Mostly Lazarus trunk and FPC 3.2 on Manjaro Linux 64-bit.

dseligo

  • Hero Member
  • *****
  • Posts: 1221
Re: Lazarus not restoring project editor state when loading LPI
« Reply #6 on: February 25, 2024, 11:56:08 am »
Description of error:
- Set up my IDE as if I am programming, have various units and forms open
- File > Save All
- File > Close All
- File > Open > (select LPI) and in the popup pick "Open Project"
- Project comes up but is empty in the IDE and I have to manually re-open units and forms.

As JuhaManninen said, don't do 'File > Close All' - you are saying to Lazarus to close files in your project.
If you want to explicitly close project, then go to menu Project and choose 'Close Project'.

When you want to open project, go to menu Project and choose 'Open Project' (or press Ctrl+F11) and Lazarus will open your project without asking to open it as XML file.

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9874
  • Debugger - SynEdit - and more
    • wiki
Re: Lazarus not restoring project editor state when loading LPI
« Reply #7 on: February 25, 2024, 01:43:30 pm »
"File" => "Close All"

This only refers to (source) files. It will close all open editor tabs. But it will not close the project.

When you then close the IDE, it will save to the session that no editors were open, and so that is the state to restore to.

In other words, "File" => "Close All"  is something you rarely ever need.


As for the (potentially) next question.... "Project" => "Close Project": Yes, it will ask/force you to open a new project (or exit the IDE).

You can not edit any files in the IDE without a project open. That is simple not possible.


KodeZwerg

  • Hero Member
  • *****
  • Posts: 2069
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Lazarus not restoring project editor state when loading LPI
« Reply #8 on: February 25, 2024, 02:03:36 pm »
"File" => "Close All"

This only refers to (source) files. It will close all open editor tabs. But it will not close the project.

When you then close the IDE, it will save to the session that no editors were open, and so that is the state to restore to.

In other words, "File" => "Close All"  is something you rarely ever need.


As for the (potentially) next question.... "Project" => "Close Project": Yes, it will ask/force you to open a new project (or exit the IDE).

You can not edit any files in the IDE without a project open. That is simple not possible.
When I did started with FreePascal, this was for me also very confusing.
When your root is Delphi (or actual any application) where "File -> Close All" does mean "Close all files and ask to save if it changed", of course that includes the project files as well.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

QuinnMartin

  • New Member
  • *
  • Posts: 28
Re: Lazarus not restoring project editor state when loading LPI (SOLVED)
« Reply #9 on: February 25, 2024, 04:15:52 pm »
Ahhhh ok.  Problem is solved now.  Thanks, I figured it had to be something dumb on my end since it seemed no one else was having issues.

Coming fresh from Delphi I was unaware that the Project Save/Open functionality had been split off and moved to the Project menu.  I just didn't see it when using the menus.

I guess there should be a "Common Mistakes" FAQ, this would be a good one to put in there.

Thank you all.

n7800

  • Jr. Member
  • **
  • Posts: 92
Re: Lazarus not restoring project editor state when loading LPI
« Reply #10 on: February 25, 2024, 04:38:24 pm »
"File" => "Close All"

This only refers to (source) files. It will close all open editor tabs. But it will not close the project.

I must say that I always saw this menu command and also thought that it closed the project. I just always immediately opened a new project, so I didn’t use it. When might such a function even come in handy?

It may at least ask for confirmation, since losing a session in a project can be very unpleasant. In the message, she may explain that this will close the files, not the project. This seems to be especially unexpected for Delphi users.

n7800

  • Jr. Member
  • **
  • Posts: 92
Re: Lazarus not restoring project editor state when loading LPI (SOLVED)
« Reply #11 on: April 12, 2024, 07:30:01 am »
I created an issue and attached the patch: https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/40895.

 

TinyPortal © 2005-2018