From c7a21c72f22c87250402df4202d791a911dc0b9e Mon Sep 17 00:00:00 2001 From: Dominik Demuth Date: Wed, 22 Nov 2023 18:30:17 +0100 Subject: [PATCH] graph keys were not deleted in tabs because of tab switching; closes #150 --- src/gui_qt/main/mainwindow.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/gui_qt/main/mainwindow.py b/src/gui_qt/main/mainwindow.py index 1eaac8e..24f3f8a 100644 --- a/src/gui_qt/main/mainwindow.py +++ b/src/gui_qt/main/mainwindow.py @@ -371,26 +371,28 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): val_figure = self.valuewidget.connected_figure self.valuewidget.remove_graph() + _remove_pts = False + _remove_t1 = False + w = None for w in self.area.subWindowList(): wdgt = w.widget() if wdgt.id == gid: wdgt.disconnect() wdgt.scene.disconnect() + if wdgt == self.current_graph_widget: if self.ptsselectwidget.connected_figure == gid: self.ptsselectwidget.connected_figure = None for line in self.ptsselectwidget.pts_lines: self.current_graph_widget.remove_external(line) - - # TODO: removing tabs creates an unholy mess because it calls toggle_tabs - self.tabWidget.removeTab(self.tabWidget.indexOf(self.ptsselectwidget)) + _remove_pts = True if self.t1tauwidget.connected_figure == gid: self.t1tauwidget.connected_figure = None self.current_graph_widget.add_external(self.t1tauwidget.min_pos) self.current_graph_widget.add_external(self.t1tauwidget.parabola) - self.tabWidget.removeTab(self.tabWidget.indexOf(self.t1tauwidget)) + _remove_t1 = True if self.fit_dialog.connected_figure == gid: self.fit_dialog.connected_figure = None @@ -417,6 +419,11 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow): break + if _remove_t1: + self.tabWidget.removeTab(self.tabWidget.indexOf(self.t1tauwidget)) + if _remove_pts: + self.tabWidget.removeTab(self.tabWidget.indexOf(self.ptsselectwidget)) + if w is not None: self.area.removeSubWindow(w) w.close()