From abbf9d2fbd47810a72f14280458952a2a1d70f75 Mon Sep 17 00:00:00 2001 From: tangkong Date: Wed, 18 Sep 2024 13:06:33 -0700 Subject: [PATCH] MNT: close and deleteLater widget when tab is removed --- superscore/widgets/window.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/superscore/widgets/window.py b/superscore/widgets/window.py index 9c22828..98d13f3 100644 --- a/superscore/widgets/window.py +++ b/superscore/widgets/window.py @@ -49,7 +49,7 @@ def setup_ui(self) -> None: # always use scroll area and never truncate file names tab_bar.setUsesScrollButtons(True) tab_bar.setElideMode(QtCore.Qt.ElideNone) - self.tab_widget.tabCloseRequested.connect(self.tab_widget.removeTab) + self.tab_widget.tabCloseRequested.connect(self.remove_tab) # setup tree view self.tree_model = RootTree(base_entry=self.client.backend.root, @@ -61,6 +61,13 @@ def setup_ui(self) -> None: # setup actions self.action_new_coll.triggered.connect(self.open_collection_builder) + def remove_tab(self, tab_index: int) -> None: + """Remove the requested tab and delete the widget""" + widget = self.tab_widget.widget(tab_index) + widget.close() + widget.deleteLater() + self.tab_widget.removeTab(tab_index) + def _update_tab_title(self, tab_index: int) -> None: """Update a DataWidget tab title. Assumes widget.title exists""" title_text = self.tab_widget.widget(tab_index)._title