graph keys were not deleted in tabs because of tab switching; closes #150

This commit is contained in:
Dominik Demuth 2023-11-22 18:30:17 +01:00
parent 929bb80f2f
commit c7a21c72f2

View File

@ -371,26 +371,28 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
val_figure = self.valuewidget.connected_figure val_figure = self.valuewidget.connected_figure
self.valuewidget.remove_graph() self.valuewidget.remove_graph()
_remove_pts = False
_remove_t1 = False
w = None w = None
for w in self.area.subWindowList(): for w in self.area.subWindowList():
wdgt = w.widget() wdgt = w.widget()
if wdgt.id == gid: if wdgt.id == gid:
wdgt.disconnect() wdgt.disconnect()
wdgt.scene.disconnect() wdgt.scene.disconnect()
if wdgt == self.current_graph_widget: if wdgt == self.current_graph_widget:
if self.ptsselectwidget.connected_figure == gid: if self.ptsselectwidget.connected_figure == gid:
self.ptsselectwidget.connected_figure = None self.ptsselectwidget.connected_figure = None
for line in self.ptsselectwidget.pts_lines: for line in self.ptsselectwidget.pts_lines:
self.current_graph_widget.remove_external(line) self.current_graph_widget.remove_external(line)
_remove_pts = True
# TODO: removing tabs creates an unholy mess because it calls toggle_tabs
self.tabWidget.removeTab(self.tabWidget.indexOf(self.ptsselectwidget))
if self.t1tauwidget.connected_figure == gid: if self.t1tauwidget.connected_figure == gid:
self.t1tauwidget.connected_figure = None self.t1tauwidget.connected_figure = None
self.current_graph_widget.add_external(self.t1tauwidget.min_pos) self.current_graph_widget.add_external(self.t1tauwidget.min_pos)
self.current_graph_widget.add_external(self.t1tauwidget.parabola) 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: if self.fit_dialog.connected_figure == gid:
self.fit_dialog.connected_figure = None self.fit_dialog.connected_figure = None
@ -417,6 +419,11 @@ class NMRMainWindow(QtWidgets.QMainWindow, Ui_BaseWindow):
break 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: if w is not None:
self.area.removeSubWindow(w) self.area.removeSubWindow(w)
w.close() w.close()