Skip to content

Commit

Permalink
fix: _disconnect_dock_widget
Browse files Browse the repository at this point in the history
  • Loading branch information
fdrgsp committed Feb 29, 2024
1 parent 275fe23 commit 4d4b0e0
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/napari_micromanager/_gui_objects/_toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ def _show_dock_widget(self, key: str = "") -> None:
wdg = ScrollableWidget(self, title=key, widget=wdg)
dock_wdg = self._add_dock_widget(wdg, key, floating=floating, tabify=tabify)
self._connect_dock_widget(dock_wdg)
dock_wdg.destroyed.connect(self._disconnect_dock_widget)
self._dock_widgets[key] = dock_wdg

def _add_dock_widget(
Expand Down Expand Up @@ -239,6 +240,13 @@ def _connect_dock_widget(self, dock_wdg: QDockWidget) -> None:
dock_wdg.topLevelChanged.connect(self._save_layout)
dock_wdg.dockLocationChanged.connect(self._save_layout)

def _disconnect_dock_widget(self) -> None:
"""Disconnect the dock widget from the main window."""
dock_wdg = cast(QDockWidget, self.sender())
dock_wdg.visibilityChanged.disconnect(self._save_layout)
dock_wdg.topLevelChanged.disconnect(self._save_layout)
dock_wdg.dockLocationChanged.disconnect(self._save_layout)

def _on_dock_widget_changed(self) -> None:
"""Start a saving threrad to save the layout if the thread is not running."""

Expand Down

0 comments on commit 4d4b0e0

Please sign in to comment.