mirror of
https://github.com/KenanZhu/AutoLibrary.git
synced 2026-08-02 06:09:36 +08:00
fix(config): ConfigManager.get() 返回深拷贝,消除跨模块字典原地修改
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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 # = []
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user