fix(ui): guard project plan cleanup after qt child deletion
This commit is contained in:
1 parent
8b8d2beefe
commit
51597ad9fc
3 files changed
+34
No files matched your search
@@ -0,0 +1,20 @@
|
||||
# PR #11 评论 #149 修复验证
|
||||
|
||||
## 根因
|
||||
|
||||
评论 #149 报告完整 UI/DSH 套件在 fixture 清理阶段访问已被 Qt 回收的 `ProjectPlanPanel.report_toggle`,错误为 `RuntimeError: Internal C++ object (QToolButton) already deleted`。相关测试单独运行会通过,问题只在完整测试顺序和窗口销毁时序下暴露。
|
||||
|
||||
## 修复
|
||||
|
||||
`ProjectPlanPanel._restore_bom_report()` 在更新报告控件前使用 `shiboken6.isValid()` 检查自身和 Qt 子控件。内存中的 BOM 预览仍照常释放;控件已经由 Qt 回收时跳过 UI 更新,避免清理路径再次调用已失效的 C++ 包装器。
|
||||
|
||||
新增回归覆盖子控件已被回收后调用 `discard_all()` 的情况;修复前稳定复现评论中的异常,修复后通过。
|
||||
|
||||
## 验证
|
||||
|
||||
- 相关 UI/生命周期回归:70 passed。
|
||||
- 完整套件:**1819 passed,1 skipped,1 warning,0 error**。
|
||||
- 跳过项为本机缺少 DxDesigner 7.9.5 生成 type library;警告为 pywinauto 的预期 COM 线程模式提示。
|
||||
- Python 编译、JS 语法和 `git diff --check` 通过。
|
||||
|
||||
未修改 PR #10 分支,未操作真实 CAD、远端工单或冻结 EXE。
|
||||
@@ -10,6 +10,7 @@ from PySide6.QtGui import QAction,QKeySequence
|
||||
from PySide6.QtWidgets import (QDialog, QDialogButtonBox, QFileDialog, QHBoxLayout, QLabel,
|
||||
QLineEdit, QListWidget, QListWidgetItem, QMessageBox, QPushButton,
|
||||
QVBoxLayout, QWidget, QToolButton, QMenu)
|
||||
from shiboken6 import isValid
|
||||
|
||||
from .detail_windows import BomReportDialog
|
||||
from .target_table import TargetTable
|
||||
@@ -669,6 +670,11 @@ class ProjectPlanPanel(QWidget):
|
||||
self.report_toggle.setChecked(False)
|
||||
|
||||
def _restore_bom_report(self, scope):
|
||||
# Qt may reclaim an owned control while the parent window is already
|
||||
# closing. Cleanup still needs to release the in-memory preview, but
|
||||
# must not call into a dead C++ wrapper.
|
||||
if not isValid(self) or not isValid(self.report_toggle):
|
||||
return
|
||||
machine = self._bom_imports.get(scope)
|
||||
state = machine.state if machine is not None else BomImportState()
|
||||
self.last_bom_report = state.report
|
||||
|
||||
@@ -10,6 +10,14 @@ from PySide6.QtCore import Signal
|
||||
from PySide6.QtWidgets import QMessageBox,QWidget
|
||||
|
||||
|
||||
def test_project_plan_discard_is_safe_after_qt_reclaims_report_control(ui, qtbot):
|
||||
"""Fixture cleanup must tolerate a child control reclaimed during window teardown."""
|
||||
import shiboken6
|
||||
report_toggle = ui.window.plan_panel.report_toggle
|
||||
shiboken6.delete(report_toggle)
|
||||
ui.window.plan_panel.discard_all()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('scope',['single','batch'])
|
||||
@pytest.mark.parametrize('stop_kind',['none','pause','force','pause_then_reauthorize'])
|
||||
def test_last_failed_item_keeps_stop_intent_in_automatic_diagnosis(ui,qtbot,monkeypatch,scope,stop_kind):
|
||||
|
||||
Reference in new issue
Block a user