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
This commit is contained in:
Jiří Paleček
2019-10-06 10:25:43 -04:00
committed by Kurt Hindenburg
parent b358110842
commit 2de43394c9

View File

@@ -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<int> ids = group.readEntry("Sessions", QList<int>());
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<TerminalDisplay *>(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));