From dfa9ae1a0c3b4fb97e69b5bf90cf445ea0b7d2d1 Mon Sep 17 00:00:00 2001 From: KenanZhu <3471685733@qq.com> Date: Fri, 26 Jun 2026 11:10:28 +0800 Subject: [PATCH] =?UTF-8?q?fix(config):=20ConfigManager.get()=20=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E6=B7=B1=E6=8B=B7=E8=B4=9D,=E6=B6=88=E9=99=A4?= =?UTF-8?q?=E8=B7=A8=E6=A8=A1=E5=9D=97=E5=AD=97=E5=85=B8=E5=8E=9F=E5=9C=B0?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/gui/ALBulletinDialog.py | 3 +-- src/gui/ALBulletinPoller.py | 2 +- src/gui/ALMainWindow.py | 7 +++++++ src/gui/ALTimerTaskHistoryDialog.py | 2 +- src/gui/ALTimerTaskManageWidget.py | 5 +++++ src/managers/config/ConfigManager.py | 5 +++-- 6 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/gui/ALBulletinDialog.py b/src/gui/ALBulletinDialog.py index a670d94..df823c0 100644 --- a/src/gui/ALBulletinDialog.py +++ b/src/gui/ALBulletinDialog.py @@ -344,10 +344,9 @@ class ALBulletinDialog(QDialog, Ui_ALBulletinDialog): return bulletin = item.data(Qt.UserRole) if bulletin.get("isNew", False): - bulletin["isNew"] = False + self.__bulletin_mgr.markBulletinAsRead(bulletin["id"]) widget = self.BulletinListWidget.itemWidget(item) if widget: widget.markAsRead() item.setData(Qt.UserRole, bulletin) - self.__bulletin_mgr.markBulletinAsRead(bulletin["id"]) self.showBulletin(bulletin) diff --git a/src/gui/ALBulletinPoller.py b/src/gui/ALBulletinPoller.py index 730847e..54edf35 100644 --- a/src/gui/ALBulletinPoller.py +++ b/src/gui/ALBulletinPoller.py @@ -164,7 +164,7 @@ class ALBulletinPoller(QObject): if str(b.get("id", "")) and str(b.get("id", "")) not in old_ids } new_ids -= delete_id_set - if new_ids: + if new_ids and not self.__dialog_open: self.newBulletinsDetected.emit(len(new_ids)) if not self.__stopped: interval_ms = self.__mgr.syncInterval()*60*1000 diff --git a/src/gui/ALMainWindow.py b/src/gui/ALMainWindow.py index 5eb2b42..bda5133 100644 --- a/src/gui/ALMainWindow.py +++ b/src/gui/ALMainWindow.py @@ -401,6 +401,13 @@ class ALMainWindow(MsgBase, QMainWindow, Ui_ALMainWindow): self ): + if self.__ALTimerTaskManageWidget is None: + QMessageBox.warning( + self, + "警告 - AutoLibrary", + "定时任务功能初始化失败, 请检查配置文件。" + ) + return self.__ALTimerTaskManageWidget.show() self.__ALTimerTaskManageWidget.raise_() self.__ALTimerTaskManageWidget.activateWindow() diff --git a/src/gui/ALTimerTaskHistoryDialog.py b/src/gui/ALTimerTaskHistoryDialog.py index 2267bf2..5220fb0 100644 --- a/src/gui/ALTimerTaskHistoryDialog.py +++ b/src/gui/ALTimerTaskHistoryDialog.py @@ -135,4 +135,4 @@ class ALTimerTaskHistoryDialog(QDialog): self.__history.clear() self.HistoryTableWidget.setRowCount(0) - self.__task_data["repeat_history"] = self.__history + self.__task_data["repeat_history"] = self.__history # = [] diff --git a/src/gui/ALTimerTaskManageWidget.py b/src/gui/ALTimerTaskManageWidget.py index d97ef6b..6c10251 100644 --- a/src/gui/ALTimerTaskManageWidget.py +++ b/src/gui/ALTimerTaskManageWidget.py @@ -515,6 +515,11 @@ class ALTimerTaskManageWidget(CenterOnParentMixin, QWidget, Ui_ALTimerTaskManage task: dict ): + # Here we use reference to task data, not copy. + # So any change of task data in history dialog will be + # reflected in the timer task list + # Thus we can emit timerTasksChanged signal to + # update config file Dialog = ALTimerTaskHistoryDialog(self, task) if Dialog.exec() == QDialog.DialogCode.Accepted: self.timerTasksChanged.emit() diff --git a/src/managers/config/ConfigManager.py b/src/managers/config/ConfigManager.py index 0b152e1..024ce6a 100644 --- a/src/managers/config/ConfigManager.py +++ b/src/managers/config/ConfigManager.py @@ -7,6 +7,7 @@ This software is provided "as is", without any warranty of any kind. You may use, modify, and distribute this file under the terms of the MIT License. See the LICENSE file for details. """ +import copy import os import threading @@ -124,13 +125,13 @@ class ConfigManager: with self.__lock: config_data = self.__config_data[key.config_type.value] if key.key == "": - return config_data + return copy.deepcopy(config_data) keys = key.key.split('.') for k in keys[:-1]: config_data = config_data.get(k, None) if config_data is None: return default - return config_data.get(keys[-1], default) + return copy.deepcopy(config_data.get(keys[-1], default)) def set( self,