code icon indicating copy to clipboard operation
code copied to clipboard

Ensure changes saved when closing

Open jeremypw opened this issue 3 years ago • 5 comments

Fix #1183

This makes most saving related functions explicitly asynchronous and where possible simpler (fewer parameters/conditionals). When closing the app, saving changes is decoupled from actually closing the documents so that any name changes during saving are properly remembered. The delete signal is blocked - the app can only be destroyed after changes have finished being saved. Obviously, if the app receives the KILL signal changes will not be saved so logging out with unsaved changes will not save them.

A function was renamed to make its action clearer and less ambiguous.

Closing a tab or the app immediately after editing a file should save the changes properly, if necessary showing a dialog (which can stop the app closing).

jeremypw avatar Apr 06 '22 17:04 jeremypw

Hello Jeremy, I did a quick test (just edited a text file and quickly closed the app via the close button and also via CTRL+Q shortcut) and it appears to be working, except the "remember opened files" part apparently. If I open a second document and come back to the first test document and edit and close, then subsequent launch of the app returns to the second document and not the first one which I had just edited and closed. The saving part is working though, with no leftover temporary .goutputstream-XXX files.

As for the code changes , I only skimmed through and looks like this refactoring is good to have even if it is a bit large, subject to approval from a reviewer more familiar with the codebase.

vjr avatar Apr 07 '22 07:04 vjr

Thanks for the quick test Vishal - I'll look into that issue you found. I think there might be another issue whereby the number of holds on the app does not reduce to zero under some circumstances as well. I'll leave as draft until more thoroughly tested.

jeremypw avatar Apr 07 '22 08:04 jeremypw

Just managed to generate a .goutputstream-XXX file somehow :disappointed: Not sure how to reproduce yet. More work needed ...

jeremypw avatar Apr 07 '22 08:04 jeremypw

Last commit fixes the incorrect focused document on restore issue.

jeremypw avatar Apr 07 '22 10:04 jeremypw

Not sure how I managed to get duplicate commits!

jeremypw avatar Apr 07 '22 10:04 jeremypw

Just converting to draft temporarily as there are few minor changes pending that need testing. Need to ensure that it still works nicely with autosave and strip trailing space.

jeremypw avatar Jan 19 '23 08:01 jeremypw

@zeebok Thanks for the review! It has been automatically dismissed I am afraid as I pushed some further commits. Hopefully no further changes will be needed but I intend to test it over the next day or two.

jeremypw avatar Jan 19 '23 17:01 jeremypw

Last commits introduced a serious bug I need to track down ...

jeremypw avatar Jan 22 '23 12:01 jeremypw

Closing in favour of a new PR consolidating saving code into DocumentManager, simplifying where possible.

jeremypw avatar Jan 29 '23 18:01 jeremypw