SUMMARY If Kate is not closed using "file->quit" from the menu bar, all of the files in the sessions are cleared and the session is saved as empty, overwriting any previous session information as well --- that is, all of the "[Document X]" sections are removed and `Count=0` is written to the [Open Documents] section. Reproducible in both Windows and Linux/Plasma STEPS TO REPRODUCE 1. Open some files with Kate. 2. Save session. 2.5. (optional) Check the `.katesession` file for the files you have open and confirm that they exist. 3. Close application using the "X" button in the title bar. 4. Relaunch Kate, see that the "Session Chooser" lists 0 files, and no files are opened when the session is selected. OBSERVED RESULT EXPECTED RESULT SOFTWARE/OS VERSIONS Windows: Windows 10 Linux/KDE Plasma: linux 6.2.2.arch1-1 plasma-framework 5.103.0-1 plasma-workspace 5.27.2-1 Qt Version: qt5-base 5.15.8+kde+r182-1
*** Bug 472510 has been marked as a duplicate of this bug. ***
I think we did break the logic for that with the current code in /** * queryClose(), take care that after the last mainwindow the stuff is closed */ bool KateMainWindow::queryClose() { // session saving, can we close all views ? // just test, not close them actually if (qApp->isSavingSession()) { return queryClose_internal(); } // normal closing of window // if we are not the last window, just close the documents we own if (KateApp::self()->mainWindowsCount() > 1) { return winClosesDocuments() ? queryClose_internal(nullptr, this) : true; } // last one: check if we can close all documents, try run // and save docs if we really close down ! if (queryClose_internal()) { KateApp::self()->sessionManager()->saveActiveSession(true); KateApp::self()->stashManager()->stashDocuments(KateApp::self()->sessionManager()->activeSession()->config(), KateApp::self()->documentManager()->documentList()); return true; } return false; }
Hmmm, or the session save timer does that on shutdown. void KateSessionManager::initTimer() { if (m_sessionSaveTimer) { qWarning() << "Session save timer is already initalized! should not happen"; return; } m_sessionSaveTimer = std::make_unique<QTimer>(); m_sessionSaveTimer->setInterval(5000); m_sessionSaveTimer->setSingleShot(true); auto *t = m_sessionSaveTimer.get(); auto dm = KateApp::self()->documentManager(); auto startTimer = [t] { if (!t->isActive()) { t->start(); } }; connect(dm, &KateDocManager::documentCreated, t, startTimer); connect(dm, &KateDocManager::documentDeleted, t, startTimer); m_sessionSaveTimer->callOnTimeout(this, [this] { saveActiveSession(true); }); }
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1272
If somebody could test my patch that would be awesome.
Git commit 772450c9fb3217373ab3d279dfc5df0b4c741d3c by Christoph Cullmann. Committed on 01/08/2023 at 19:33. Pushed by cullmann into branch 'master'. avoid that the session save timer messes up session saving we need to ensure it doesn't trigger during window/app closing M +3 -0 apps/lib/kateapp.cpp M +6 -0 apps/lib/katemainwindow.cpp M +19 -28 apps/lib/session/katesessionmanager.cpp M +40 -3 apps/lib/session/katesessionmanager.h https://invent.kde.org/utilities/kate/-/commit/772450c9fb3217373ab3d279dfc5df0b4c741d3c
Git commit f459fc544c31efbee9645612ee517f73a2808886 by Christoph Cullmann. Committed on 02/08/2023 at 21:20. Pushed by cullmann into branch 'release/23.08'. avoid that the session save timer messes up session saving we need to ensure it doesn't trigger during window/app closing (cherry picked from commit 772450c9fb3217373ab3d279dfc5df0b4c741d3c) M +3 -0 apps/lib/kateapp.cpp M +6 -0 apps/lib/katemainwindow.cpp M +19 -28 apps/lib/session/katesessionmanager.cpp M +40 -3 apps/lib/session/katesessionmanager.h https://invent.kde.org/utilities/kate/-/commit/f459fc544c31efbee9645612ee517f73a2808886
I hope this is fixed, if somebody can confirm with a master build that would be great.
*** Bug 467877 has been marked as a duplicate of this bug. ***
This was still an issue up until 24.05.0 so not sure it was the same as the linked bug but it's working now! Thanks!