From 389ac885d3185607057742477e9864176f300b9f Mon Sep 17 00:00:00 2001 From: KenanZhu <3471685733@qq.com> Date: Tue, 11 Nov 2025 09:05:55 +0800 Subject: [PATCH] fix(ALMainWindow): optimize the resource usage of gui This commit fixes memory management issues in the ALMainWindow class where config window and task threads were not properly deleted after use, leading to continuously increasing memory usage. The fix ensures that all GUI components are deleted after close and background threads are correctly terminated. --- gui/ALMainWindow.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gui/ALMainWindow.py b/gui/ALMainWindow.py index 5f7dc04..642d86a 100644 --- a/gui/ALMainWindow.py +++ b/gui/ALMainWindow.py @@ -242,6 +242,8 @@ class ALMainWindow(QMainWindow, Ui_ALMainWindow): config_paths: dict ): + self.__alConfigWidget.configWidgetCloseSingal.disconnect(self.onConfigWidgetClosed) + self.__alConfigWidget.deleteLater() self.__alConfigWidget = None self.ConfigButton.setEnabled(True) self.StartButton.setEnabled(True) @@ -288,8 +290,12 @@ class ALMainWindow(QMainWindow, Ui_ALMainWindow): ): if self.__auto_lib_thread and self.__auto_lib_thread.isRunning(): - self.__auto_lib_thread.stop() self.showTrace("正在停止操作......") + self.__auto_lib_thread.stop() + self.__auto_lib_thread.wait() + self.showTrace("操作已停止") + self.__auto_lib_thread.finishedSignal.disconnect(self.onStopButtonClicked) + self.__auto_lib_thread.deleteLater() self.setControlButtons(True, True, False) @Slot()