Recent

Author Topic: I lost a half a days time coding and I am not sure why  (Read 806 times)

CarmichaelJohn

  • New Member
  • *
  • Posts: 34
I lost a half a days time coding and I am not sure why
« on: September 20, 2020, 03:54:00 am »
Hello,
I am in the process of porting a large Delphi program that calculates statistical distributions of many types.  Today I was copying the Pascal code from the Delphi Program, procedure by procedure, and pasting it into the new Lazarus program, doing substantial editing along with the pasting.  I save my work regularly with the "Save All" option on the File menu.  Then when I went back to Delphi for more code and returned to Lazarus, all of my work was gone.  There was a box that appeared that asked if I wanted to reload from disk, and being unfamiliIar with the intricacies of Lazarus, I ignored the reload option. Was this my disasterous error,  or is there something else I should have done.  Pray tell, how do I do this back and forth porting thing safely?
Thank you in advance, John

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1014
  • Former Delphi 1-7, 10.2 User
Re: I lost a half a days time coding and I am not sure why
« Reply #1 on: September 20, 2020, 03:58:26 am »
Not sure what happened, but check the backup directory in your project's directory and there should be a copy of the previous file.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r47164, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (Parallels VM)

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6676
  • Debugger - SynEdit - and more
    • wiki
Re: I lost a half a days time coding and I am not sure why
« Reply #2 on: September 20, 2020, 04:16:57 am »
Quote
There was a box that appeared that asked if I wanted to reload from disk
So some other program (editor outside Lazarus), had the same files open. And that other editor had changed them.

Lazarus notices that, and offers to reload them.

Then I can only guess / One possible scenario / but there could be others, I do not know what was the 2nd application changing your files on the disk:
Assuming the version in Lazarus was up to date, then you did right not to reload them, because whatever was on disk was different on out of date.
If you saved the files from Lazarus, that would have updated the disk versions. But maybe the other program/editor was still open, and replaced the files?



There is another possibility:
If you have symlinks (e.g. ntfs directory mountpoints), and 2 path point to the same physical file, and you open that files from both locations, then you can fool Lazarus to believe that this are 2 diff files, and it will compete with itself.

wp

  • Hero Member
  • *****
  • Posts: 7642
Re: I lost a half a days time coding and I am not sure why
« Reply #3 on: September 20, 2020, 10:43:55 am »
Use a version control system to commit a snapshot of your project whenever a self-contained piece is completed. This way you can always go back to previous stages of your work in case something goes wrong.

You seem to be on Windows. Install TortoiseSVE or TortoiseGIT. They provide extensions to the Windows explorer context menu and to give you quick access to creating repositories, making a commit (svn)/push (git) (= save to repository) or an update (svn) / pull (git) (= load from repository).

doing substantial editing along with the pasting
I would not do this. Take two steps: transfer to Lazarus first, and then do the edits. When you combine the steps and something does not work any more after the transfer you don't know whether this is due to the changes made for the transfer or due to the edits.

Having done several transfers I also want to point you to the decision whether you want the final program to be usable in Lazarus only, or also in Delphi. Transfering to Lazarus is usually a one-way street - you cannot compile the project in Delphi any more. Being able to go back to Delphi *IS*possible but you must keep this in mind whenever you make a change in any file.
« Last Edit: September 20, 2020, 11:16:48 am by wp »
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

avra

  • Hero Member
  • *****
  • Posts: 2016
    • Additional info
Re: I lost a half a days time coding and I am not sure why
« Reply #4 on: September 21, 2020, 10:22:07 am »
There was a box that appeared that asked if I wanted to reload from disk
Did you edit the same project in both Delphi and Lazarus at the same time? Or did you use some external editor instead of Lazarus built in?
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

BosseB

  • Sr. Member
  • ****
  • Posts: 279
Re: I lost a half a days time coding and I am not sure why
« Reply #5 on: September 22, 2020, 11:22:57 am »
I save my work regularly with the "Save All" option on the File menu.
I was hit with some unknown problem where Lazarus would just disappear (crash) while I was editing code.
It was a VNC remote session to a RaspberryPi where I am developing stuff for RPi usage.

After this happened a few times and I lost like you the edits I had been doing since the last SaveAll I started looking for a better solution.
And it was easier than I figured!
In OnLine Package Manager there is a package called AutoSave. It attaches to Lazarus itself and adds a File option for automatically saving work to disk every so often. I have it set for 5 seconds...

After this Lazarus might crash or act up, the files as they were 5 s ago will be on disk!

Notice though that AutoSave does not save the project file, just pascal source files open in the editor.

Of course I also use Subversion for daily commits of work files, but that is another story and cannot be used to guard against problems like ours.
--
Bo Berglund
Sweden

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 6676
  • Debugger - SynEdit - and more
    • wiki
Re: I lost a half a days time coding and I am not sure why
« Reply #6 on: September 22, 2020, 01:01:31 pm »
I was hit with some unknown problem where Lazarus would just disappear (crash) while I was editing code.
It was a VNC remote session to a RaspberryPi where I am developing stuff for RPi usage.
Have you ever reported that?
Ideally with a stacktrace, where the crash happens?

If it still happens, I will happily guide you how to get a trace.

BosseB

  • Sr. Member
  • ****
  • Posts: 279
Re: I lost a half a days time coding and I am not sure why
« Reply #7 on: September 22, 2020, 04:50:06 pm »
I was hit with some unknown problem where Lazarus would just disappear (crash) while I was editing code.
It was a VNC remote session to a RaspberryPi where I am developing stuff for RPi usage.
Have you ever reported that?
Yes, on the Lazarus mailing list.
It seems like it is hard to debug since it seems to involve how VNC transfers mouse and keyboard events to the host.
Most often Lazarus crashed when I was making some mouse operation, like selecting a word or just moving the pointer from one place to another. And it could last hours before it happened...
Quote

Ideally with a stacktrace, where the crash happens?

If it still happens, I will happily guide you how to get a trace.
I don't see this very often nowadays since I started using screen 0 for VNC, previously I always used screen 1 and it was started in /etc/rc.local. I did that in order to easily set a screen resolution that fit my needs.
But since there were other issues as well concerning special key handling I tried to switch to screen 0 and after that there were no longer any crashes AFAICR...

I keep using AutoSave though, because it saves me problems if he RPi would restart with a session open and unsaved.

--
Bo Berglund
Sweden

BosseB

  • Sr. Member
  • ****
  • Posts: 279
Re: I lost a half a days time coding and I am not sure why
« Reply #8 on: September 25, 2020, 09:49:28 am »
In response to a PM that was sent to me by @CarmichaelJohn I am posting this since the PM functionality of this forum seems to be broken...

Thank you again for your response to my questions (I lost a half days coding..) about my program being lost when I saved (using "Save All" frequently).  I have been looking for AutoSave in OnLine Project Manager but cannot find it.  Where is it located?
Thank you, John

This is available in Packages/OnLine Package Manager
If you go there you will find it close to the top as shown in the screenshot I have made:

--
Bo Berglund
Sweden

 

TinyPortal © 2005-2018