hydrogen-music / hydrogen

The advanced drum machine for Linux, macOS, and Windows
http://www.hydrogen-music.org
GNU General Public License v2.0
1.04k stars 173 forks source link

Remove autosave files when user declines to restore from them #1962

Open cme opened 6 months ago

cme commented 6 months ago

Remove autosave files when user declines to restore from them

When Hydrogen starts up, if a file has been autosaved the user will be offered the opportunity to restore from that file. If they decline it, Hydrogen should delete the autosaved file; it may be soon overwritten anyway by new autosave data.

This avoids the annoying cycle I often find myself in:

  1. edit file
  2. quit Hydrogen discarding edits (but autosave remains)
  3. open Hydrogen
  4. hit "Don't Save" because I didn't want those edits
  5. listen to original file without modifying (hence no autosave, but old autosave remains)
  6. quit Hydrogen (silently)
  7. goto 3

Also, when opening a file and restoring from its autosave, Hydrogen should count this as the song being Modified because the current content is from the autosave and is not the same as the content of the named file.

This change also removes spurious sets of IsModified in parts of the GUI, which would setIsModified( true ) in the GUI initialisation despite not making any actual changes, as well as setModified( false ) calls that were needed to work around these spurious sets after song loading completed.

theGreatWhiteShark commented 6 months ago

Haha, setting autosave to 0 is also the first thing I do. It's quite annoying during development.

If they decline it, Hydrogen should delete the autosaved file

I also noted that. In #1955 I used a "No" instead of "Discard" button. But breaking the cycles sound like a very good idea.

How about we offer all three options: yes, no, discard. This way the user can view both original and modified version before deciding whether to discard or apply the changes.

cme commented 6 months ago

How about we offer all three options: yes, no, discard. This way the user can view both original and modified version before deciding whether to discard or apply the changes.

Excellent idea, I like it.

cme commented 6 months ago

Oh good catch, I'll look into it. Thanks.