Bug 449229 - Save and restore unsaved files doesn't work when closing app with Ctrl+Q; changes are silently lost
Summary: Save and restore unsaved files doesn't work when closing app with Ctrl+Q; cha...
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: sessions (show other bugs)
Version: 20.12.1
Platform: OpenSUSE Linux
: VHI critical (vote)
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-01-27 08:34 UTC by Grósz Dániel
Modified: 2022-02-10 21:45 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 21.12.3


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Grósz Dániel 2022-01-27 08:34:53 UTC
SUMMARY
When automatic saving and restoring of unsaved changes is enabled, and there are unsaved changes, Kate quits without asking for confirmation—but it doesn't actually restore changes when it's started again.

STEPS TO REPRODUCE
1. If you don't currently have a saved session, create and save one.
2. In Configure/Session, enable Automatically save and restore: Files with unsaved changes.
3. Open a file, and make some changes.
4. Quit Kate.
5. Start Kate again.

OBSERVED RESULT
The changes are lost. The swap file is deleted when you quit Kate.

EXPECTED RESULT
The changes are restored.

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20220124
KDE Plasma Version: 5.23.5
KDE Frameworks Version: 5.90.0
Qt Version: 5.15.2
Graphics Platform: X11
Comment 1 Nate Graham 2022-01-27 20:48:07 UTC
I reported this 10 months ago in https://invent.kde.org/utilities/kate/-/merge_requests/228#note_198079 and can confirm that the issue is still present.
Comment 2 Méven Car 2022-01-29 16:07:23 UTC
I can reproduce it if I quit Kate using Quit or Ctrl+Q shortcut but not when using Alt+F4.
Am I the only one in this situation ?
Comment 3 Grósz Dániel 2022-01-29 22:10:48 UTC
(In reply to Méven Car from comment #2)
> I can reproduce it if I quit Kate using Quit or Ctrl+Q shortcut but not when
> using Alt+F4.
> Am I the only one in this situation ?

This indeed seems to be the case.

If I make some changes, then exit with Alt+F4 (or closing the window with the mouse), then I restart Kate, and quit with Ctrl+Q, then even the changes made before quitting with Alt+F4 are lost.
Comment 4 Nate Graham 2022-01-29 23:55:03 UTC
That probably explains why others weren't able to reproduce it. I always quit apps with Ctrl+Q and never use Alt+F4. Curious that these use different codepaths.
Comment 5 Kai Uwe Broulik 2022-02-05 22:29:44 UTC
> Curious that these use different codepaths.

One is explicitly quitting, the other is closing the window where Qt goes "alrght, all my windows are closed, better quit now". 

I suppose file_quit action is explicitly wired to save the session and then calls qApp->quit, whereas Qt just calls quits internally, effectively bypassing the save.
Comment 6 Grósz Dániel 2022-02-05 22:56:21 UTC
(In reply to Kai Uwe Broulik from comment #5)
> > Curious that these use different codepaths.
> 
> One is explicitly quitting, the other is closing the window where Qt goes
> "alrght, all my windows are closed, better quit now". 
> 
> I suppose file_quit action is explicitly wired to save the session and then
> calls qApp->quit, whereas Qt just calls quits internally, effectively
> bypassing the save.

But it's the other way around: unsaved changes are retained when quitting by closing the window (Alt+F4), and doesn't work when quitting with File/Quit (Ctrl+Q).
Comment 7 Christoph Cullmann 2022-02-08 16:38:53 UTC
Git commit 0319a51438be5170f75c99b8ad72de7a1354c585 by Christoph Cullmann, on behalf of Waqar Ahmed.
Committed on 08/02/2022 at 16:35.
Pushed by cullmann into branch 'master'.

Fix stashing not working when Kate is quit using Ctrl+Q

M  +1    -0    kate/kateapp.cpp

https://invent.kde.org/utilities/kate/commit/0319a51438be5170f75c99b8ad72de7a1354c585
Comment 8 Christoph Cullmann 2022-02-08 16:43:44 UTC
Git commit 9f87e0106a912237e586db592f4d6eae396f673d by Christoph Cullmann, on behalf of Waqar Ahmed.
Committed on 08/02/2022 at 16:43.
Pushed by cullmann into branch 'release/21.12'.

Fix stashing not working when Kate is quit using Ctrl+Q


(cherry picked from commit 0319a51438be5170f75c99b8ad72de7a1354c585)

M  +1    -0    kate/kateapp.cpp

https://invent.kde.org/utilities/kate/commit/9f87e0106a912237e586db592f4d6eae396f673d