diff --git a/src/ViewContainer.cpp b/src/ViewContainer.cpp --- a/src/ViewContainer.cpp +++ b/src/ViewContainer.cpp @@ -90,6 +90,8 @@ connect(this, &TabbedViewContainer::currentChanged, this, [this](int index) { if (index != -1) { widget(index)->setFocus(); + } else { + deleteLater(); } }); @@ -145,8 +147,6 @@ auto view = widget(i); disconnect(view, &QWidget::destroyed, this, &Konsole::TabbedViewContainer::viewDestroyed); } - - emit destroyed(this); } void TabbedViewContainer::moveTabToWindow(int index, QWidget *window) diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -877,8 +877,10 @@ QList list; TabbedViewContainer *container = _viewSplitter->activeContainer(); + if (container == nullptr) { + return {}; + } - Q_ASSERT(container); list.reserve(container->count()); for(int i = 0, end = container->count(); i < end; i++) { diff --git a/src/ViewSplitter.h b/src/ViewSplitter.h --- a/src/ViewSplitter.h +++ b/src/ViewSplitter.h @@ -170,9 +170,6 @@ void updateSizes(); private Q_SLOTS: - // Called to indicate that a child ViewContainer has been deleted - void containerDestroyed(TabbedViewContainer *container); - // Called to indicate that a child ViewContainer is empty void containerEmpty(TabbedViewContainer *container); diff --git a/src/ViewSplitter.cpp b/src/ViewSplitter.cpp --- a/src/ViewSplitter.cpp +++ b/src/ViewSplitter.cpp @@ -23,6 +23,7 @@ #include "ViewSplitter.h" // Qt +#include // Konsole #include "ViewContainer.h" @@ -88,13 +89,6 @@ void ViewSplitter::registerContainer(TabbedViewContainer *container) { _containers << container; - // Connecting to container::destroyed() using the new-style connection - // syntax causes a crash at exit. I don't know why. Using the old-style - // syntax works. - //connect(container , static_cast(&Konsole::ViewContainer::destroyed) , this , &Konsole::ViewSplitter::containerDestroyed); - //connect(container , &Konsole::ViewContainer::empty , this , &Konsole::ViewSplitter::containerEmpty); - connect(container, SIGNAL(destroyed(TabbedViewContainer*)), this, - SLOT(containerDestroyed(TabbedViewContainer*))); connect(container, SIGNAL(empty(TabbedViewContainer*)), this, SLOT(containerEmpty(TabbedViewContainer*))); } @@ -179,29 +173,23 @@ } } -void ViewSplitter::containerEmpty(TabbedViewContainer * /*container*/) +void ViewSplitter::containerEmpty(TabbedViewContainer * myContainer) { + _containers.removeAll(myContainer); + if (count() == 0) { + emit empty(this); + } + int children = 0; - foreach (TabbedViewContainer *container, _containers) { + foreach (auto container, _containers) { children += container->count(); } if (children == 0) { emit allContainersEmpty(); } } -void ViewSplitter::containerDestroyed(TabbedViewContainer *container) -{ - Q_ASSERT(_containers.contains(container)); - - _containers.removeAll(container); - - if (count() == 0) { - emit empty(this); - } -} - void ViewSplitter::activateNextContainer() { TabbedViewContainer *active = activeContainer();