Recent

Author Topic: "Do you want to save your project before exiting?"  (Read 7513 times)

AndrejM

  • New member
  • *
  • Posts: 9
"Do you want to save your project before exiting?"
« on: November 07, 2008, 09:54:05 pm »
*Edit*
Please check my 2nd post
*Edit*

Bart

  • Hero Member
  • *****
  • Posts: 3538
    • Bart en Mariska's Webstek
RE: "Do you want to save your project before exiting?&q
« Reply #1 on: November 09, 2008, 12:14:42 am »
But it does, just edit one of the sourcefiles, close Lazarus and it will ask you if you want to save, discard changes, or cancel closing the IDE.

If however you replaced code, then saved the file, then close Lazarus, it will close without asking.
This is probably what you have done.

Bart

AndrejM

  • New member
  • *
  • Posts: 9
RE: "Do you want to save your project before exiting?&a
« Reply #2 on: November 09, 2008, 05:00:17 am »
I'm sorry, I misunderstood what I've done here, and seem to have found what the problem is. It's not during the closing and opening stage, it's something else:

If I make any changes to the code, the project is still not saved. However if I want to test the code and I click the Run button, Lazarus automatically saves the project without asking me if I want to save the project or not. This is really ackward, as sometimes I want to just test a peace of code before I decide to save my project. And if Lazarus crashes while trying to compile, the old peace of code is permanently lost (since after a crash you can't use the Undo option).

As a workaround I guess I could wrap the peace of code I want to replace with brackets {} so the compiler ignores them (as it ignores comments), but this really isn't an efficient way to backup and replace a peace of code.

Wouldn't it be better if Lazarus created a temporary project file when it needs to compile the project which was recently edited?

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
Re: RE: "Do you want to save your project before exitin
« Reply #3 on: November 09, 2008, 09:15:10 am »
First thing to keep in mind: the compiler cannot compile source from memory, it needs source in files on disks.

Quote from: AndrejM
If I make any changes to the code, the project is still not saved. However if I want to test the code and I click the Run button, Lazarus automatically saves the project without asking me if I want to save the project or not.
It does this on a temporary place, and the project is still marked as unsaved.
Quote
This is really ackward, as sometimes I want to just test a peace of code before I decide to save my project. And if Lazarus crashes while trying to compile, the old peace of code is permanently lost (since after a crash you can't use the Undo option).
Yes. If Lazarus crashed, you cannot undo your changes. I don't think that can be remedied.

Quote
As a workaround I guess I could wrap the peace of code I want to replace with brackets {} so the compiler ignores them (as it ignores comments), but this really isn't an efficient way to backup and replace a peace of code.
Why not save it, or use publish project to copy project sources to a safe place?

Quote
Wouldn't it be better if Lazarus created a temporary project file when it needs to compile the project which was recently edited?
Isn't that what happens, it creates a temporary project file, if you haven't saved the project yet. If it is saved already, it tells the compiler to use that file.
« Last Edit: December 23, 2008, 11:51:00 am by Vincent Snijders »

AndrejM

  • New member
  • *
  • Posts: 9
"Do you want to save your project before exiting?"
« Reply #4 on: November 09, 2008, 04:54:05 pm »
Quote
It does this on a temporary place, and the project is still marked as unsaved.

Not true. As soon as I press the run button lazarus saves the project file.

There is a way to retrieve the code if I only edited and run the project once. Since the last known state of the source code is saved in a backup file, I can open that backup file instead.

However If I change some code, Run the project, change some code again and Run the project again: In this situation Lazarus only keeps the last known state of the code in the backup file, but not the one before I've Run the compiler in the first place. This is because it saves the original project file whenever I hit the Run button, and saves the Backup file to the version before it.

I can record a youtube clip if you want to. I'm not making this up.

Bart

  • Hero Member
  • *****
  • Posts: 3538
    • Bart en Mariska's Webstek
"Do you want to save your project before exiting?"
« Reply #5 on: November 12, 2008, 01:38:08 pm »
I do not consider this behaviour to be bad or a bug.
On the contrary I'm glad Lazarus saves my projectfile on run. At least in that way, all my newly written code is not lost if my app crashes Lazarus (or my computer if I develop under windows).
If I do significant rewrites of a project, and I'm not sure if that is gonn turn out as a good thing in the end, I make a backup of my project before I starte tempering with my working code.
I've done so since I started TP and later Delphi, both of which were kind enougth to also save upon run.

But that's just my opinion.

Bart