From f240cbc30966c115cab02fd7612e6891850552a8 Mon Sep 17 00:00:00 2001 From: wakonig_k Date: Fri, 18 Apr 2025 12:14:13 +0200 Subject: [PATCH] wip --- .../containers/main_window/main_window.py | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/bec_widgets/widgets/containers/main_window/main_window.py b/bec_widgets/widgets/containers/main_window/main_window.py index 7b0cc5bf..099ef930 100644 --- a/bec_widgets/widgets/containers/main_window/main_window.py +++ b/bec_widgets/widgets/containers/main_window/main_window.py @@ -5,6 +5,7 @@ from qtpy.QtGui import QAction, QActionGroup, QIcon from qtpy.QtWidgets import QApplication, QMainWindow, QStyle import bec_widgets +from bec_widgets.cli.rpc.rpc_register import RPCRegister from bec_widgets.utils import UILoader from bec_widgets.utils.bec_widget import BECWidget from bec_widgets.utils.colors import apply_theme @@ -169,19 +170,20 @@ class BECMainWindow(BECWidget, QMainWindow): apply_theme(theme) def cleanup(self): - central_widget = self.centralWidget() - central_widget.close() - central_widget.deleteLater() - if not isinstance(central_widget, BECWidget): - # if the central widget is not a BECWidget, we need to call the cleanup method - # of all widgets whose parent is the current BECMainWindow - children = self.findChildren(BECWidget) - for child in children: - ancestor = WidgetHierarchy._get_becwidget_ancestor(child) - if ancestor is self: - child.cleanup() - child.close() - child.deleteLater() + with RPCRegister.delayed_broadcast(): + central_widget = self.centralWidget() + central_widget.close() + central_widget.deleteLater() + if not isinstance(central_widget, BECWidget): + # if the central widget is not a BECWidget, we need to call the cleanup method + # of all widgets whose parent is the current BECMainWindow + children = self.findChildren(BECWidget) + for child in children: + ancestor = WidgetHierarchy._get_becwidget_ancestor(child) + if ancestor is self: + child.cleanup() + child.close() + child.deleteLater() super().cleanup()