Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#2819 closed defect (fixed)

[PATCH][ATLAS]Add a unsaved changes check on exiting Atlas

Reported by: Niek Owned by: trompetin17
Priority: Should Have Milestone: Alpha 18
Component: Atlas editor Keywords:
Cc: Patch:

Description (last modified by Niek)

It would be nice to ask for confirmation on exiting Atlas if there are unsaved changes (and it saves me for wasting more hours on Scenario Designing just because I forgot to save the map :))

Attachments (7)

2819.patch (11.8 KB ) - added by trompetin17 10 years ago.
2819_III.patch (11.8 KB ) - added by trompetin17 10 years ago.
2819_III.2.patch (1.3 KB ) - added by trompetin17 10 years ago.
2819_dic.diff (2.6 KB ) - added by trompetin17 9 years ago.
2819_dic.2.diff (2.9 KB ) - added by trompetin17 9 years ago.
2819_dic.3.diff (3.5 KB ) - added by trompetin17 9 years ago.
2819_dic.4.diff (4.0 KB ) - added by trompetin17 9 years ago.

Download all attachments as: .zip

Change History (24)

comment:1 by Niek, 10 years ago

Description: modified (diff)

by trompetin17, 10 years ago

Attachment: 2819.patch added

comment:2 by trompetin17, 10 years ago

Keywords: review patch added
Summary: [ATLAS]Add a unsaved changes check on exiting Atlas[PATCH][ATLAS]Add a unsaved changes check on exiting Atlas

comment:3 by Niek, 10 years ago

Description: modified (diff)

comment:4 by Niek, 10 years ago

The patch provided by trompetin17 works as expected. Modify the map and you'll get a confirmation box when you're trying to exit with unsaved changes. There is one thing I however want to add, if you undo all the way back to a saved state it still comes up with that warning (while technically it is saved, it only is modified and reverted afterwards)

comment:5 by Niek, 10 years ago

I think this is a proper way to handle the behavior suggested above:

  • Keep track of the undo history.
  • Mark the first map state as the initial state (this is the state when you just loaded the map, without any changes.
  • If you save the map, mark that state as the saved state. If the saved state is not present in the undo history (either because you didn't save the map yet or because you undo-ed and made changes again) don't care about it (no need to check the file system if the current state is exactly the state of the saved map). If it isn't in the undo history you won't realistically reach the exact state (without reloading the map) anyway.

comment:6 by Itms, 10 years ago

Keywords: review removed

After looking more closely at the code, I think niektb's suggestion is better.

Indeed, you had to add manually a notification to the editor for each change, so if someone adds a new way to change the map, they'll have to add this notification too. I think the undo/redo approach is saner.

About the style, I'll just suggest some English changes, and I'll review seriously the future version of the patch, as you'll have to change a significant part of your code.

  • m_changesWithoutSave -> m_needsSave or something like this
  • "The map has not been saved... continue closing?" -> "You have unsaved changes. Are you sure you want to quit?" is more standard
  • "Please confirm" -> "Discard unsaved changes?" is also more standard

¡Gracias por trabajar sobre eso! ;-)

by trompetin17, 10 years ago

Attachment: 2819_III.patch added

comment:7 by trompetin17, 10 years ago

Done, could you review again please :)

by trompetin17, 10 years ago

Attachment: 2819_III.2.patch added

comment:8 by trompetin17, 9 years ago

Keywords: review added

comment:9 by Itms, 9 years ago

Type: taskdefect

Ok, I tested the patch. I really like how it is now, just some style comments:

  • Beware the trailing spaces on lines 581, 748, 773, 788
  • your comments "change the flag" are useless, and I'd write "Check for unsaved changes" on line 572 (also please write //(space)Your text)

Now, about the functionality, you should also perform the check when opening another map, or when creating a new one, etc. After that I think it will be ok :)

comment:10 by trompetin17, 9 years ago

Itms, could you re-check, i added some configuration in my xcode about "indentation", hope this help.

And about functionality i added a check in "OnOpen", "OnMRUFile" and "OnImportHeightmap".

by trompetin17, 9 years ago

Attachment: 2819_dic.diff added

comment:11 by Stan, 9 years ago

Is it necessary to add one for the RMG ?

by trompetin17, 9 years ago

Attachment: 2819_dic.2.diff added

in reply to:  11 comment:12 by trompetin17, 9 years ago

Sorry what does mean RMG?

Replying to stanislas69:

Is it necessary to add one for the RMG ?

comment:13 by trompetin17, 9 years ago

Itms, i made another change, could you re-re-re-review ? :$

comment:14 by Stan, 9 years ago

Random map generation. =)

by trompetin17, 9 years ago

Attachment: 2819_dic.3.diff added

in reply to:  14 comment:15 by trompetin17, 9 years ago

Added, thx for your warning

2819_dic.3.diff

Replying to stanislas69:

Random map generation. =)

by trompetin17, 9 years ago

Attachment: 2819_dic.4.diff added

comment:16 by Itms, 9 years ago

Resolution: fixed
Status: newclosed

In 16126:

Check for unsaved changes in Atlas. Patch by trompetin17, fixes #2819.

comment:17 by Itms, 9 years ago

Keywords: review Atlas patch removed

Thanks for the patch!

Note: See TracTickets for help on using tickets.