Disable "detach-tab" after closing others

Other signals are received too early when closing tabs.
ViewContainer::viewRemoved is received after the tab count has been
updated.

Protect against the "detach-tab" action when only one left.

Fixes the following behavior:
 - Create two tabs
 - Close one tab
 - Detach the remaining tab through menu or shortcut
 - The original window is blank - no terminal display. Adding a tab
   to it crashes
wilder
Nathan Sprangers 5 years ago committed by Tomaz Canabrava
parent d37d3ac11f
commit aa6193b0a8
  1. 5
      src/ViewManager.cpp

@ -295,6 +295,8 @@ void ViewManager::setupActions()
connect(_viewContainer, &TabbedViewContainer::viewAdded, this, &ViewManager::toggleActionsBasedOnState);
connect(_viewContainer, &QTabWidget::currentChanged, this, &ViewManager::toggleActionsBasedOnState);
// Let the view container remove the view before counting tabs
connect(_viewContainer, &TabbedViewContainer::viewRemoved, this, &ViewManager::toggleActionsBasedOnState);
toggleActionsBasedOnState();
}
@ -445,6 +447,9 @@ void ViewManager::detachActiveView()
void ViewManager::detachActiveTab()
{
if (_viewContainer->count() < 2) {
return;
}
const int currentIdx = _viewContainer->currentIndex();
detachTab(currentIdx);
}

Loading…
Cancel
Save