Bug 498425 - The save file on exit dialogue does not respect the choice of discarding changes to a file
Summary: The save file on exit dialogue does not respect the choice of discarding chan...
Status: REPORTED
Alias: None
Product: kate
Classification: Applications
Component: sessions (other bugs)
Version First Reported In: 24.12.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-09 12:05 UTC by Filip
Modified: 2025-01-17 11:01 UTC (History)
2 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 Filip 2025-01-09 12:05:15 UTC
SUMMARY
When Kate asks the changes to be saved on exit, clicking "Discard" will not discard the changes

STEPS TO REPRODUCE
1. Uncheck/Disable the the following option in Kate config:
	Session -> Automatically save and restore: [ ] Files with unsaved changes
2. Open an existing file in Kate
3. Make changes to the file
4. To track the changes, Kate creates *.kate-swp (next to the file), which is fine
5. Close Kate
6. Kate asks if you want to save the changes to the file. Now click "Discard"
8. Start Kate again

OBSERVED RESULT
Kate now complains that the file was not closed properly, and asks if I want to recover the data.
(I assume this is because Kate did not delete *.kate-swp when I clicked "Discard")

EXPECTED RESULT
Kate should not report that the file was not closed properly, because it should have discarded my changes to the file
(I assume Kate should delete *.kate-swp when I clicked "Discard")

SOFTWARE/OS VERSIONS
KDE Frameworks Version: 6.9.0
Qt Version: 6.8.1
Comment 1 Christoph Cullmann 2025-01-11 19:02:31 UTC
Hmmm, that seems strange, could you check if Kate did crash on shutdown?
Comment 2 Filip 2025-01-12 10:59:43 UTC
It seems that kate closes gracefully when I click "Discard". I don't see any traces of crash in the logs.

$ journalctl --since "1 min ago" | grep -i kate
Jan 12 11:28:09 vivo kate[11964]: kate.time: QApplication initialized in 80 ms
Jan 12 11:28:09 vivo kate[11964]: libkate.time: -> katefiletreeplugin load in 1 ms
Jan 12 11:28:09 vivo kate[11964]: libkate.time: -> katesearchplugin load in 4 ms
Jan 12 11:28:09 vivo kate[11964]: libkate.time: -> kateprojectplugin load in 0 ms
Jan 12 11:28:09 vivo kate[11964]: libkate.time: -> externaltoolsplugin load in 0 ms
Jan 12 11:28:09 vivo kate[11964]: libkate.time: -> katekonsoleplugin load in 0 ms
Jan 12 11:28:09 vivo kate[11964]: libkate.time: -> lspclientplugin load in 2 ms
Jan 12 11:28:09 vivo kate[11964]: libkate.time: -> tabswitcherplugin load in 0 ms
Jan 12 11:28:09 vivo kate[11964]: libkate.time: -> textfilterplugin load in 0 ms
Jan 12 11:28:09 vivo kate[11964]: libkate.time: All plugins loaded in 10 ms
Jan 12 11:28:09 vivo kate[11964]: libkate.time: Created KateMainWindow in 55 ms
Jan 12 11:28:09 vivo kate[11964]: kate.time: KateApp initialized in 124 ms
Jan 12 11:28:33 vivo systemd[1103]: Started Kate - Advanced Text Editor.
Jan 12 11:28:33 vivo kate[12019]: kate.time: QApplication initialized in 76 ms
Jan 12 11:28:33 vivo kate[12019]: libkate.time: -> katefiletreeplugin load in 1 ms
Jan 12 11:28:33 vivo kate[12019]: libkate.time: -> katesearchplugin load in 4 ms
Jan 12 11:28:33 vivo kate[12019]: libkate.time: -> kateprojectplugin load in 0 ms
Jan 12 11:28:33 vivo kate[12019]: libkate.time: -> externaltoolsplugin load in 0 ms
Jan 12 11:28:33 vivo kate[12019]: libkate.time: -> katekonsoleplugin load in 0 ms
Jan 12 11:28:33 vivo kate[12019]: libkate.time: -> lspclientplugin load in 2 ms
Jan 12 11:28:33 vivo kate[12019]: libkate.time: -> tabswitcherplugin load in 0 ms
Jan 12 11:28:33 vivo kate[12019]: libkate.time: -> textfilterplugin load in 0 ms
Jan 12 11:28:33 vivo kate[12019]: libkate.time: All plugins loaded in 11 ms
Jan 12 11:28:33 vivo kate[12019]: libkate.time: Created KateMainWindow in 55 ms
Jan 12 11:28:33 vivo kate[12019]: kate.time: KateApp initialized in 111 ms
Jan 12 11:28:42 vivo systemd[1103]: app-org.kde.kate@31cc4d0b96734b45a0639d05bef1313e.service: Consumed 392ms CPU time, 68.4M memory peak.
Comment 3 John Kizer 2025-01-16 06:21:08 UTC
Hi - I can't reproduce using those steps on Kate 24.12.1, Fedora KDE 41. I wonder if, perhaps, some other session-related setting is interacting with the one you specified? The settings I have that are nearby in the Configure Kate > Session dialog are below - could you please share yours to double-check?

Application Startup Behavior: Manually choose a session
Automatically save and restore: Newly-created unsaved files (yes), Files with unsaved changes (no)
Show welcome view for new windows: Yes
Close the application entirely when the last file is closed: No
Close documents with the window they belong to: Yes
Comment 4 Filip 2025-01-16 12:30:13 UTC
I've updated Kate to v24.12.1 and I'm still having this issue

My settings are almost the opposite of what you have though:

Application Startup Behavior: Load last used session
Automatically save and restore: Newly-created unsaved files (no), Files with unsaved changes (no)
Show welcome view for new windows: No
Close the application entirely when the last file is closed: Yes
Close documents with the window they belong to: Yes
Comment 5 Filip 2025-01-16 12:50:37 UTC
Btw I've just retested with your settings above, and I'm still seing the issue, so it must be something else
Comment 6 Filip 2025-01-16 13:00:21 UTC
Also just to emphasize: There is no issue when I close the tab of the unsaved file. Clicking "Discard" in that case works as expected. I'm facing the issue only when I close the whole application while the file is still unsaved.
Comment 7 John Kizer 2025-01-17 00:04:50 UTC
(In reply to Filip from comment #6)
> Also just to emphasize: There is no issue when I close the tab of the
> unsaved file. Clicking "Discard" in that case works as expected. I'm facing
> the issue only when I close the whole application while the file is still
> unsaved.

Yep, that's how I closed it as well - and I tried changing my Session settings to yours, and still couldn't reproduce it - so indeed, something else is going on!
Comment 8 Filip 2025-01-17 11:01:47 UTC
I also reset my kate settings to default (by removing $HOME/.config/katerc), which did not fix the issue either. I was thinking that maybe there is some sort of race condition that makes kate close before it could remove the kate-swp file. But then the issue should also be present when I click "Save" on exit. However in that case, kate (saves the edited file and) removes the kate-swp file with no issues. So I'm now out of ideas what could cause this.