Fix the fallback code used when restoring session fails

Summary:
 When restoring session in Konsole fails, the fallback code should
 create a default view and session instead. However, the code omitted
 adding this view to the container, which makes

 - the window black (or grey in my case), see
   https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=935031

 - konsole crash later, when you add a new tab and close it, because
   code in ViewManager expects TerminalDisplays to be children of
   ViewSplitter, which is not the case

 This fix adds the view to activeController(), just like every other
 code that creates TerminalDisplay.

Test Plan:
 1. find a session in your $HOME/.config/session/ from konsole before 19.08
 2. konsole -session xxxx (where xxxx are the numbers in the session file)
    -> there should be a konsole window with usable terminal
 3. add a new tab with C-S-T and close it
    ->there should be no crash

Reviewers: hindenburg, #konsole

Reviewed By: hindenburg, #konsole

Subscribers: tcanabrava, konsole-devel

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D23601
This commit is contained in:
Jiří Paleček
2019-09-01 18:31:37 -04:00
committed by Kurt Hindenburg
parent 7e83be4719
commit 656f6804ea

View File

@@ -938,7 +938,7 @@ void ViewManager::restoreSessions(const KConfigGroup &group)
if (jsonTabs.isEmpty()) { // Session file is unusable, start default Profile
Profile::Ptr profile = ProfileManager::instance()->defaultProfile();
Session *session = SessionManager::instance()->createSession(profile);
createView(session);
activeContainer()->addView(createView(session));
if (!session->isRunning()) {
session->run();
}