Prevent window "flashing" when closing the last session

There are two scenarios when closing a window:
A) clicking the close button on the title bar (or Ctrl+Shift+Q):
~MainWindow()
~ViewManager()
~TabbedViewContainer()
~TerminalDisplay()
~Session()

B) closing the last session/tab in a window:
SessionController::sessionFinished()
~Session()
~TerminalDisplay()
~TabbedViewContainer()
~MainWindow()
~ViewManager()

the issue with the second case is that the TerminalDisplay is torn down
first, which exposes the TabbedViewContainer widget, the latter has the same
Qt::Window colour as the system colour scheme window background colour, if
you're using a dark terminal colour scheme and a light-coloured system colour
scheme, you could see some "flashing" when you close the last session with
e.g. Ctrl+D.

To fix this, in sessionFinished() check if TabbedViewContainer::count() is
1 (i.e. closing last tab/session), and emit the empty() signal in that case,
which is connected to MainwWindow::close(), then the order of tear down
becomes:
SessionController::sessionFinished()
~Session()
~MainWindow()
~ViewManager()
~TabbedViewContainer()
~TerminalDisplay()

BUG: 432077
FIXED-IN: 21.12
wilder
Ahmad Samir 5 years ago
parent 99b3959464
commit bbec72250d
  1. 2
      src/MainWindow.cpp
  2. 7
      src/ViewManager.cpp

@ -114,7 +114,7 @@ MainWindow::MainWindow() :
// create view manager // create view manager
_viewManager = new ViewManager(this, actionCollection()); _viewManager = new ViewManager(this, actionCollection());
connect(_viewManager, &Konsole::ViewManager::empty, this, &Konsole::MainWindow::close); connect(_viewManager, &Konsole::ViewManager::empty, this, &QWidget::close);
connect(_viewManager, &Konsole::ViewManager::activeViewChanged, this, connect(_viewManager, &Konsole::ViewManager::activeViewChanged, this,
&Konsole::MainWindow::activeViewChanged); &Konsole::MainWindow::activeViewChanged);
connect(_viewManager, &Konsole::ViewManager::unplugController, this, connect(_viewManager, &Konsole::ViewManager::unplugController, this,

@ -494,6 +494,13 @@ void ViewManager::sessionFinished()
return; return;
} }
// The last session/tab? emit empty() so that close() is called in
// MainWindow, fixes #432077
if (_viewContainer->count() == 1) {
Q_EMIT empty();
return;
}
auto *session = qobject_cast<Session *>(sender()); auto *session = qobject_cast<Session *>(sender());
Q_ASSERT(session); Q_ASSERT(session);

Loading…
Cancel
Save