IsmAvatar / LateralGM

A free Game Maker source file editor
http://lateralgm.org/
Other
95 stars 25 forks source link

Backup Preferences #178

Closed RobertBColton closed 4 years ago

RobertBColton commented 9 years ago

This is somewhat a sort of feature request. User showed up today and LGM froze on Fedora acting like a modal dialog was open, user could not save or close and had to kill the process losing about 15 minutes of work. The request here is simple, add a preference that makes System.Exit() automatically write a backup somewhere in LGM's working directory in cases like this where the program is still open but the user can't reach the save dialog.

It would be best to catch system.exit() is a separate thread somehow, if it's even possible. Josh suggested just doing a save every few seconds or so, obviously make it preference to set the time.

IsmAvatar commented 9 years ago

Just wanted to leave a note here that your proposed solution has a couple pitfalls.

That all said, I'm certainly not opposed to any kind of automated backup as long as it can be turned off and does not inhibit the user's workflow. I tried to design the saving module with different backup strategies in mind, so hopefully it's modular enough to easily do any strategy you want to do with minimal refactoring.

RobertBColton commented 9 years ago

@IsmAvatar I'll propose another alternative you hadn't thought about as well. If say we forced conversion to the GMX format like Studio's IDE we would have the project always exist on disk and could force the user to save before running and only save the resources that changed, that way if some goes wrong usually only 1 or 2 resources is lost, plus it induces saving more frequently because the saves are quicker as well and not just one giant blob. What do you think about just converting GMK's to GMX on load like GM: Studio?

A lot of people would like this because of the optimizations I could make, but I've always had the philosophy of finishing the other parts of the IDE first. What do you think Ism?

IsmAvatar commented 9 years ago

That's exactly what I had in mind - or rather our own format EGM rather than the proprietary GMX. Nobody cares what format the automatic Backup is in, as long as the file that they manually export is in the format that they manually specify, and in a reasonable time.

Also, if we've overwriting the backup and it is prone to easy corruptions (e.g. the resource you're trying to save becomes corrupted, and takes out the entire EGM in the process), then we should take extra precautions to alleviate that, such as making a second backup.

For example:

if( file_exists( backup ) ) {
 if( sanity_check( backup ) ) {
  file_copy( from = backup, to = backup2 )
 }
 backup_modify( backup )
} else {
 backup_new( backup )
}

(Just to get an idea what I was thinking - feel free to take as much creative liberty as you'd like)

RobertBColton commented 4 years ago

I am going to close this as 39b37b4adecf603fe9ba3d55efb209fdcb1ce1bf has now completed these preferences and made them functional. The part of the discussion here involving automatic conversion to GMX or EGM can be saved for another time, because it involves a lot more than just backups. Also I should point out that it seems part of the original issue, the IDE freezing, may have been related to the initial thread safety which #506 just resolved.

The following image was my initial proposal for the backup preferences, and we did end up going with a slightly modified and cleaned up version of it. Initial Backup Preferences Proposal

The two options we can see removed were the "On Exit" and "Hours" settings. The exit preference was removed until it can be added later and tied to the close unsaved changes dialog. It would basically be tied to a checkbox on the dialog that says "Don't ask again" but we need that in a couple more places first. The "Hours" setting was removed because I felt it was self-defeating to wait that long before doing an autosave. Also, hours can be represented quite obviously as minutes, and since the Java Swing timer class uses an integer delay, the max would be 2147483647 milliseconds which is enough room to cover 596~ hours. Final Backup Preferences Proposal

Ideally the exit preference would be added as a checkbox below the other backup preferences and "Exit saves without confirmation" would be a good choice of wording. The checkbox's preference would be the same as a checkbox which appears directly on the close unsaved changes dialog. Ask Save Changes on Exit