1
0
mirror of https://github.com/bec-project/bec_widgets.git synced 2026-03-04 16:02:51 +01:00

fix(performance_bundle): fix performance bundle cleanup

This commit is contained in:
2025-07-17 12:38:49 +02:00
committed by Jan Wyzula
parent 1d8069e391
commit 23674ccf59
3 changed files with 10 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ from __future__ import annotations
from typing import TYPE_CHECKING
from bec_widgets.utils.error_popups import SafeSlot
from bec_widgets.utils.toolbars.actions import MaterialIconAction
from bec_widgets.utils.toolbars.bundles import ToolbarBundle
from bec_widgets.utils.toolbars.connections import BundleConnection
@@ -42,11 +43,15 @@ class PerformanceConnection(BundleConnection):
super().__init__()
self._connected = False
@SafeSlot(bool)
def set_fps_monitor(self, enabled: bool):
setattr(self.target_widget, "enable_fps_monitor", enabled)
def connect(self):
self._connected = True
# Connect the action to the target widget's method
self.components.get_action_reference("fps_monitor")().action.toggled.connect(
lambda checked: setattr(self.target_widget, "enable_fps_monitor", checked)
self.set_fps_monitor
)
def disconnect(self):
@@ -54,5 +59,6 @@ class PerformanceConnection(BundleConnection):
return
# Disconnect the action from the target widget's method
self.components.get_action_reference("fps_monitor")().action.toggled.disconnect(
lambda checked: setattr(self.target_widget, "enable_fps_monitor", checked)
self.set_fps_monitor
)
self._connected = False

View File

@@ -1007,6 +1007,7 @@ class ImageBase(PlotBase):
"""
Cleanup the widget.
"""
self.toolbar.cleanup()
# Remove all ROIs
rois = self.rois

View File

@@ -1040,6 +1040,7 @@ class PlotBase(BECWidget, QWidget):
self.crosshair.update_markers()
def cleanup(self):
self.toolbar.cleanup()
self.unhook_crosshair()
self.unhook_fps_monitor(delete_label=True)
self.tick_item.cleanup()
@@ -1049,7 +1050,6 @@ class PlotBase(BECWidget, QWidget):
self.axis_settings_dialog = None
self.cleanup_pyqtgraph()
self.round_plot_widget.close()
self.toolbar.cleanup()
super().cleanup()
def cleanup_pyqtgraph(self, item: pg.PlotItem | None = None):