Bug 505135 - Unsaved files, and unsaved changes to existing files, are silently lost when closing Kate if the options to save and restore such files are enabled
Summary: Unsaved files, and unsaved changes to existing files, are silently lost when ...
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: sessions (other bugs)
Version First Reported In: 25.04.1
Platform: openSUSE Linux
: NOR critical
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
: 505481 (view as bug list)
Depends on:
Blocks:
 
Reported: 2025-06-02 18:55 UTC by Grósz Dániel
Modified: 2025-06-20 16:09 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Grósz Dániel 2025-06-02 18:55:09 UTC
SUMMARY
If the Automatically save and restore Newly-created unsaved files and/or Files with unsaved changes options are enabled, Kate doesn't prompt if there are unsaved changes when closing it, but the changes are not restored when reopening the session.

In the case of newly created unsaved files, tabs corresponding to unsaved files get opened when reopening Kate, but they are empty.

STEPS TO REPRODUCE
1. Open Kate with a saved session.
2. Under Settings / Configure Kate... / Sessions, enable Automatically save and restore Files with unsaved changes (or Newly-created unsaved files), if it's not already enabled.
3. Close Kate and open it again with the saved session. (I'm not sure if this step is necessary, it seems to me that these settings don't fully take effect for already opened sessions.)
4. Open a file (or create a new file).
5. Make some changes (but don't save it).
6. Close Kate.
7. Reopen Kate with the same session.

OBSERVED RESULT
The contents of the file are as before the changes (or it's empty, in the case of a new file).

EXPECTED RESULT
The changes are preserved.

SOFTWARE/OS VERSIONS
Operating System: openSUSE Tumbleweed 20250522
KDE Plasma Version: 6.3.5
KDE Frameworks Version: 6.14.0
Qt Version: 6.9.0
Kernel Version: 6.14.6-1-default (64-bit)
Graphics Platform: X11

ADDITIONAL INFORMATION
Unlike the earlier, similar Bug 449229, it happens whether I quit Kate with Ctrl+Q or by closing the window.
Could be related to the fixing of Bug 497478, a bug in 24.12.0 where open files' paths randomly got replaced with those of stash files when automatic save/restore was enabled. (In 24.12.0 the automatic save/restore feature itself did work.)
Bug 493665 concerns the case when Kate is closed irregularly (SIGKILL, computer crashes etc.), but in 25.04.1 automatic save/restore seems to be entirely broken, even when quitting Kate normally.
Comment 1 John Kizer 2025-06-15 04:35:03 UTC
I can reproduce this in Kate built yesterday from git master, thanks!

Kate: 25.07.70
KDE Frameworks: 6.16.0
Qt: Using 6.9.1 and built against 6.9.1
Fedora Linux 42 (KDE Plasma Desktop Edition) (Wayland)
Build ABI: x86_64-little_endian-lp64
Kernel: linux 6.14.9-300.fc42.x86_64
Comment 2 John Kizer 2025-06-19 06:56:24 UTC
*** Bug 505481 has been marked as a duplicate of this bug. ***
Comment 3 Christoph Cullmann 2025-06-20 16:09:31 UTC
Git commit 5ec8803db140df82735bc215223f052981894bde by Christoph Cullmann, on behalf of Waqar Ahmed.
Committed on 20/06/2025 at 15:54.
Pushed by cullmann into branch 'master'.

Fix stashing not working

We need to do stashing in the saveSessionTo after it has deleted
old KConfigGroup entries. If we do it before, we end up deleting
the stash entries we just created.

Also add a test to make sure the feature is always working at a
basic level at least.

M  +38   -0    apps/lib/autotests/kate_view_mgmt_test2.cpp
M  +7    -5    apps/lib/session/katesessionmanager.cpp
M  +1    -1    apps/lib/session/katesessionmanager.h

https://invent.kde.org/utilities/kate/-/commit/5ec8803db140df82735bc215223f052981894bde