历史多触发闪退三面修:消除 model 重复路径 + 清 result_bytes + 子线程异常兜底
用户症状: 历史记录条数多时容易闪退。沿数据流追到三个独立问题。
A) core/history.py HistoryListModel._get_or_build eager 构造 QIcon
(PIL + QPixmap scaled + QIcon, ~43KB/项), 但 QML delegate 走
history.thumbnailPath() 自管缩略图, 从不引用 model.DecorationRole.
旧 QListView IconMode 路径已 .txt 化弃用. 这条 eager 路径 N=500+
时常驻 ~22MB GUI 资源 + 主线程 PIL/scaled 卡顿放大. 改为
data(DecorationRole) lazy build + 不缓存, _get_or_build 只构造
text/tooltip.
B) task_queue.py _on_task_completed emit 后立即 task.result_bytes = None.
bytes 已落 history + result_path 已写回, 内存里副本浪费.
长跑 N 条已完成任务时常驻 N * 10-15MB (2K 图), 触发 OOM/SIGKILL.
sidebar 回显走 result_path, 不受影响.
C) 诊断设施补强 (下次崩能拿到证据):
- core/runtime.py: 加 threading.excepthook (Python 3.8+).
sys.excepthook 只主线程生效, 子线程未捕获异常默认无声死亡.
- main_qml.py: aboutToQuit 加 flush_logs() 退出最后一秒 INFO 不丢.
- main_qml.py: QQmlApplicationEngine.warnings + objectCreationFailed
信号导到 logger. 之前 QML 错误仅打 stderr, frozen windowed 无痕.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Showing
4 changed files
with
73 additions
and
9 deletions
-
Please register or sign in to post a comment