Bug 464703 - Unsaved files of session cannot be saved on exit if a directory has not yet been created
Summary: Unsaved files of session cannot be saved on exit if a directory has not yet b...
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: sessions (show other bugs)
Version: 22.12.1
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-23 17:41 UTC by mpeter.68m0y
Modified: 2024-09-14 18:55 UTC (History)
2 users (show)

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


Attachments
screenshot of error popup referenced in step 5 (9.98 KB, image/png)
2023-01-23 17:41 UTC, mpeter.68m0y
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mpeter.68m0y 2023-01-23 17:41:41 UTC
Created attachment 155535 [details]
screenshot of error popup referenced in step 5

SUMMARY
If I have unsaved files opened, and I close the Kate window, it will pop up errors (one for every such file) indicating that it was not able to save it. This happens if the `kate` directory in the user appdata/roaming directory (usually at `c:\Users\<username>\AppData\Roaming\`) does not yet exist.


STEPS TO REPRODUCE
1. Make sure that the above mentioned directory does not exist
2. Open Kate
3. Save the session with "Sessions > Save Session" on the toolbar
3. Open one or more files, write something into them, but do not save them
4. Close Kate
5. Observe error popups
6. Open Kate and choose to load the saved session
7. Observe empty unsaved files

OBSERVED RESULT
Saving the session does not persist unsaved files

EXPECTED RESULT
Saving the session persists unsaved files, which are restored along with their content when reopening the session

SOFTWARE/OS VERSIONS
Windows: 10
KDE Frameworks Version: 5.102.0
Qt Version: 5.15.8

ADDITIONAL INFORMATION
Manually creating the folder at `c:\Users\<username>\AppData\Roaming\kate` fixes session restore for Kate 22.08.1, but not for 22.12.1.

On 22.12.1, the error popup does not return, and the unsaved documents are still persisted, but seemingly a new bug is present: on opening Kate and loading the session, the files are not accessible in Kate. Despite that, when loading the session, the files disappear from the `c:\Users\<username>\AppData\Roaming\kate\stash\<session name>\` directory, and reapper when Kate is closed.
I don't have access to releases between these 2 versions.
Comment 1 Waqar Ahmed 2023-02-27 05:43:20 UTC
The files will be accessible via the "Documents" pane on the left. If there is no documents pane, make sure the "documents tree view" plugin is enabled
Comment 2 mpeter.68m0y 2023-02-27 09:29:36 UTC
Oh, I see, thanks. I have found the files there.

The documents pane button was not visible at first, but I could make it visible using the Show Active Document option in the Go menu at the top. Probably I had hidden the sidebar and forgot about it.
Comment 3 Christoph Cullmann 2024-09-10 09:04:02 UTC
Git commit bb268e2be0ff118c277d2e5bffb98b6e00ece3ea by Christoph Cullmann.
Committed on 10/09/2024 at 09:03.
Pushed by cullmann into branch 'master'.

fix session restore of tabs/views of untitled documents

will allow us to restore the right tabs even for untitled documents
and avoids that we create new untitled documents on session restore
Related: bug 462112, bug 462523, bug 468573

M  +22   -1    apps/lib/katedocmanager.cpp
M  +9    -0    apps/lib/katedocmanager.h
M  +37   -16   apps/lib/kateviewspace.cpp

https://invent.kde.org/utilities/kate/-/commit/bb268e2be0ff118c277d2e5bffb98b6e00ece3ea
Comment 4 Christoph Cullmann 2024-09-13 16:57:00 UTC
Git commit be856dbb927f2c4082218bc4e0360eb677c9c44f by Christoph Cullmann.
Committed on 13/09/2024 at 16:56.
Pushed by cullmann into branch 'release/24.08'.

fix session restore of tabs/views of untitled documents

will allow us to restore the right tabs even for untitled documents
and avoids that we create new untitled documents on session restore
Related: bug 462112, bug 462523, bug 468573


(cherry picked from commit bb268e2be0ff118c277d2e5bffb98b6e00ece3ea)

1866ba36 store the id from the session we did load/save
06c49bc4 write out the id of the document and not the url
2da4f29e read both the new session stored with id and the old with url

Co-authored-by: Christoph Cullmann <christoph@cullmann.io>

M  +22   -1    apps/lib/katedocmanager.cpp
M  +9    -0    apps/lib/katedocmanager.h
M  +37   -16   apps/lib/kateviewspace.cpp

https://invent.kde.org/utilities/kate/-/commit/be856dbb927f2c4082218bc4e0360eb677c9c44f
Comment 5 mpeter.68m0y 2024-09-14 18:55:24 UTC
Thanks! I'll try to test it when I can obtain a windows build from the CI.