[Lazarus] AutoSave does not save project file...
Bo Berglund
bo.berglund at gmail.com
Thu Apr 6 09:08:45 CEST 2023
On Thu, 20 May 2021 21:10:10 +0200, Bo Berglund via lazarus
<lazarus at lists.lazarus-ide.org> wrote:
>On Sun, 11 Apr 2021 11:29:36 +0200, Bo Berglund via lazarus
><lazarus at lists.lazarus-ide.org> wrote:
>
>>I have installed AutoSave from the OnlinePackageManager on all of my numerous
>>Lazarus installations and in general it works well.
>>I started to do this following several Lazarus crashes where I lost modified
>>code and had to try restoring from memory...
>>
>>However, when I write console (simple program) applications I have noted that
>>AutoSave does not save the lpr file! And when looking closely the lpi file in
>>GUI apps is also not saved.
>>
>>Since lpr is the only file in simple programs AutoSave does not help from
>>disaster if a crash happens.
>>Is there a way to configure or modify AutoSave so it also saves the main project
>>files?
>>
>
>Reviving this thread in order to find a solution (did not get a single reply).
>------------------------------------------------------------------------------
>I am relying heavily on AutoSave when programming in Lazarus on a remote
>RaspberryPi via VNC connection. In this situation it happens way too often that
>Lazarus suddenly just unloads from memory and I see a blank desktop.
>Thanks to AutoSave in most cases I have just to start Lazarus again to be back
>in business, at worst with the last 5 seconds of typing lost.
>
>But that does not hold true if I am working in the lpr file because that is not
>saved automatically!!!
>
>It just happened to me again and it causes problems trying to re-create the last
>hour or so of work done on this file. :(
>
>So I would REALLY be happy if someone who understands the workings of AutoSave
>can make it include the project file among the files saved by AutoSave!
>
>I have never ever looked at stuff that integrate within Lazarus itself so I
>could not fix it....
Now I have looked at the GitHub code, but am none the wiser (or a little bit
wiser)...
>For a console program maybe I should create a mainprogram.pas file and put
>*everything* now located in the lpr file into that instead?
>Just leave a bare minimum in the lpr file...
>Pity to be forced to do that though.
>
As Juha Manninen suggested I have looked at the Autosave code in GitHub and I
found this to be where the action is triggered:
The file is: https://github.com/lainz/LazAutoSave/blob/master/autosave_main.pas
And this is the function that does the job (starts at line #107):
procedure TAutoSave.OnTimer(Sender: TObject);
begin
if Settings = nil then
begin
if LazarusIDE <> nil then //wait until IDE startup
begin
Settings :=
TSettings.Create(AppendPathDelim(LazarusIDE.GetPrimaryConfigPath) +
cAutoSaveConfigFile);
FTimer.StopTimer;
FTimer.Interval := Settings.AutoSaveInteval*1000;
FTimer.StartTimer;
end;
end
else
begin
if Settings.EnableAutoSave then
LazarusIDE.DoSaveAll([sfDoNotSaveVirtualFiles, sfCanAbort,
sfQuietUnitCheck]); //<== Does *not* save the project lpr file!
end;
end;
Notice that it calls LazarusIDE itself and I have no idea how to make Lazarus
include the lpr file into the ones being saved by this call...
There *must* be some setting for this in Lazarus, right?
So how can I tell Lazarus to include the lpr file in the saved files when it is
called this way?
I am still experiencing these regular crashes in Lazarus even when using the
version 2.2.6 with Fpc 3.2.2 on a RaspberryPi4B 8GB device. I access the desktop
with VNC, which may be why the crash happens.
Typically Lazarus disappears when I accidentally click the mouse on something in
the IDE, but I don't understand exactly what is clicked. Could be some border in
the editor or such, but Lazarus instantly disappears and I look at a blank
desktop...
However, Autosave has saved the day for me because when it happens I can just
start Lazarus again and I am back where I left off.
Except of course if I am doing a command line program with all code in the lpr
file, then everything is lost when the crash happens.
--
Bo Berglund
Developer in Sweden
More information about the lazarus
mailing list