Skip to content

Commit

Permalink
LV references stored in list and closed properly
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeSullivan7 committed Nov 15, 2024
1 parent 9632e94 commit c0db0d3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
7 changes: 5 additions & 2 deletions mantidimaging/gui/windows/live_viewer/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,11 @@ def set_image_index(self, index: int) -> None:

def closeEvent(self, e) -> None:
"""Close the window and remove it from the main window list"""
self.main_window.live_viewer = None
self.presenter.close()
for live_viewer in self.main_window.live_viewer_list:
if live_viewer.path == self.path:
if live_viewer.presenter:
live_viewer.presenter.close()
live_viewer.close()
self.live_viewer.handle_deleted()
super().closeEvent(e)
self.presenter = None # type: ignore # View instance to be destroyed -type can be inconsistent
Expand Down
15 changes: 8 additions & 7 deletions mantidimaging/gui/windows/main/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class MainWindowView(BaseMainWindowView):
filters: FiltersWindowView | None = None
recon: ReconstructWindowView | None = None
spectrum_viewer: SpectrumViewerWindowView | None = None
live_viewer: LiveViewerWindowView | None = None
live_viewer_list: list[LiveViewerWindowView] = []
settings_window: SettingsWindowView | None = None

image_load_dialog: ImageLoadDialog | None = None
Expand Down Expand Up @@ -474,10 +474,11 @@ def live_view_choose_directory(self) -> None:
self.show_live_viewer(Path(live_data_directory))

def show_live_viewer(self, live_data_path: Path) -> None:
self.live_viewer = LiveViewerWindowView(self, live_data_path)
self.live_viewer.activateWindow()
self.live_viewer.raise_()
self.live_viewer.show()
live_viewer = LiveViewerWindowView(self, live_data_path)
self.live_viewer_list.append(live_viewer)
self.live_viewer_list[-1].activateWindow()
self.live_viewer_list[-1].raise_()
self.live_viewer_list[-1].show()

@property
def stack_list(self) -> list[StackId]:
Expand Down Expand Up @@ -560,8 +561,8 @@ def closeEvent(self, event) -> None:
# Close additional windows which do not have the MainWindow as parent
if self.recon:
self.recon.close()
if self.live_viewer:
self.live_viewer.close()
if self.live_viewer_list:
[live_viewer.close() for live_viewer in self.live_viewer_list]
if self.spectrum_viewer:
self.spectrum_viewer.close()
if self.filters:
Expand Down

0 comments on commit c0db0d3

Please sign in to comment.