From 9d75f9edc71be71efe990e8dd86f8067268af8d0 Mon Sep 17 00:00:00 2001 From: "Martin T. H. Sandsmark" Date: Sat, 10 Oct 2020 18:36:07 -0400 Subject: [PATCH] Fix invalid cast and simplify method Part of !209 --- src/widgets/ViewContainer.cpp | 12 ++++++------ src/widgets/ViewContainer.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/widgets/ViewContainer.cpp b/src/widgets/ViewContainer.cpp index 501ecd7e..a4cf65bf 100644 --- a/src/widgets/ViewContainer.cpp +++ b/src/widgets/ViewContainer.cpp @@ -176,7 +176,7 @@ void TabbedViewContainer::moveTabToWindow(int index, QWidget *window) auto controller = splitter->activeTerminalDisplay()->sessionController(); container->currentSessionControllerChanged(controller); - forgetView(splitter); + forgetView(); } void TabbedViewContainer::konsoleConfigChanged() @@ -392,17 +392,17 @@ void TabbedViewContainer::disconnectTerminalDisplay(TerminalDisplay *display) void TabbedViewContainer::viewDestroyed(QObject *view) { - auto widget = static_cast(view); - const auto idx = indexOf(widget); + QWidget *widget = qobject_cast(view); + Q_ASSERT(widget); + const int idx = indexOf(widget); removeTab(idx); - forgetView(widget); + forgetView(); _tabIconState.remove(widget); } -void TabbedViewContainer::forgetView(ViewSplitter *view) +void TabbedViewContainer::forgetView() { - Q_UNUSED(view) if (count() == 0) { emit empty(this); } diff --git a/src/widgets/ViewContainer.h b/src/widgets/ViewContainer.h index 378b8ac3..cd058df4 100644 --- a/src/widgets/ViewContainer.h +++ b/src/widgets/ViewContainer.h @@ -222,7 +222,7 @@ private Q_SLOTS: void konsoleConfigChanged(); private: - void forgetView(ViewSplitter *view); + void forgetView(); struct TabIconState { TabIconState(): readOnly(false), broadcast(false), notification(Session::NoNotification) {}