From 2de43394c98364edd48fb74bbaa467d5d281d445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Pale=C4=8Dek?= Date: Sun, 6 Oct 2019 10:25:43 -0400 Subject: [PATCH] Allow loading of pre 19.08 session files The format of the Konsole session file changed with 19.08. This was overlooked and pre 19.08 files caused crashes. That crash was fixed in 19.08.1 to just start the default profile. This patch will allow pre 19.08 session files to be loaded correctly. BUG: 412173 FIXED-IN: 19.08.2 --- src/ViewManager.cpp | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp index 4e7367b11..42c204566 100644 --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -935,7 +935,40 @@ void ViewManager::restoreSessions(const KConfigGroup &group) _viewContainer->addSplitter(topLevelSplitter, _viewContainer->count()); } - if (jsonTabs.isEmpty()) { // Session file is unusable, start default Profile + if (!jsonTabs.isEmpty()) + return; + + // Session file is unusable, try older format + QList ids = group.readEntry("Sessions", QList()); + int activeTab = group.readEntry("Active", 0); + TerminalDisplay *display = nullptr; + + int tab = 1; + foreach (int id, ids) { + Session *session = SessionManager::instance()->idToSession(id); + + if (session == nullptr) { + qWarning() << "Unable to load session with id" << id; + // Force a creation of a default session below + ids.clear(); + break; + } + + activeContainer()->addView(createView(session)); + if (!session->isRunning()) { + session->run(); + } + if (tab++ == activeTab) { + display = qobject_cast(activeView()); + } + } + + if (display != nullptr) { + activeContainer()->setCurrentWidget(display); + display->setFocus(Qt::OtherFocusReason); + } + + if (ids.isEmpty()) { // Session file is unusable, start default Profile Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); Session *session = SessionManager::instance()->createSession(profile); activeContainer()->addView(createView(session));