fix: exit toolbar when owning DxDesigner closes

This commit is contained in:
阿白叔 committed 2026-10-13 10:10:57 +08:00
1 parent 8b1e19ff0f
commit 3a65401c23
4 files changed
+101 -2

No files matched your search

@@ -0,0 +1,42 @@
# 关闭 DX 自动退出工具验收(2026-10-13)
## 问题与修复
此前宿主监听器在所属 DX 窗口失效时仅忽略本次检查,工具继续运行。本次在已绑定的宿主窗口失效后调用统一退出入口,关闭工具栏和面板、停止定时器及各控制器,并结束 Qt 事件循环。DX 最小化仍只隐藏工具,恢复时还原此前的页面状态。
绑定沿用桥接 run ID、工程路径和原生视图的顶层 HWND/PID,不按前台窗口或进程名称选择宿主。Start 菜单注册进行中时,统一退出入口暂缓关闭;监听器继续运行,注册结束后重试退出。未绑定 DX 的独立工具维持手动退出方式。
## 自动检查
| 检查 | 结果 | 证据 |
|---|---|---|
| 修改前所属宿主消失 | 1 failed,工具未进入退出状态 | `build/test-evidence/host-close-red.xml` |
| 初次修复后宿主监听 | 9 passed,1 skipped | `build/test-evidence/host-close-green.xml` |
| 最终窗口回归 | 24 passed,1 skipped | `build/test-evidence/host-close-ui-final.xml` |
| 最终便携包 | 16 passed | `build/test-evidence/host-close-packaged-final.xml` |
窗口回归覆盖面板展开、收起、DX 最小化的四种组合,以及关闭另一宿主不退出、注册结束后重试。offscreen 跳过的是原生焦点保留用例;此前 Windows 后端结果见 `host-visibility-acceptance-20261012.md`。最终包检查包含九页入口、中文空格路径和 ZIP 校验。
更新发布说明后的一次便携包复查在复制中文路径用例时遇到 C 盘 `WinError 112`(磁盘空间不足),结果为 15 passed、1 failed;记录保留在 `build/test-evidence/host-close-packaged-disk-full.xml`。最终复查通过 `--basetemp` 使用 F 盘的独立目录,未修改产品实现。
## 实机关闭
使用独立副本 `%LOCALAPPDATA%/DxProductivity/acceptance/native-20261010/1GPHY_RTL8211F/1GPHY_RTL8211F.prj`,进入 `GE_PHY_8211` 原理图页,由持久化菜单打开最终包。
- DX PID:28712,主窗口 HWND:6628030。
- 工具 PID:67600,工具栏 HWND:1838946,面板 HWND:1249096。
- DX 最初已最小化,两处工具窗口均隐藏。恢复 DX 后工具栏显示,随后展开面板。
- 验收程序核对 DX 主窗口 PID 和工程路径后,仅向该主窗口发送 `WM_CLOSE`,未向工具发送退出指令。
- 3.047 秒内 DX 和工具进程均退出,工具栏与面板窗口均销毁。
- 工程 `.prj` 和 `sch` 目录文件的 SHA-256 在操作前后一致。
原始记录:`%LOCALAPPDATA%/DxProductivity/acceptance/host-close-20261013/before-close.json` 和 `host-close.json`。本轮实机覆盖面板展开状态;收起、隐藏和其他宿主隔离由自动回归覆盖。
## 发布包
- 目录:`release/一叶知秋_重构版_横向工具栏版`。
- ZIP:`release/一叶知秋_重构版_横向工具栏版_Win11_x64.zip`。
- ZIP SHA-256:`76a3990b4dc0d341cd502fd2c6915afb847df3f50176cdc12073b000a8a01361`。
- EXE SHA-256:`0adaeea27bd2e7a23c7840e47b76b210d12f6e3e1decb54695e00e03f4e6e352`。
此记录仅说明宿主关闭联动及相关窗口行为,不代替业务模块验收。
@@ -7,6 +7,7 @@
- 工具栏末尾使用明确的“展开 ▾ / 收起 ▴”按钮;展开内容以无标题栏卡片贴在工具栏下方,不再显示独立应用窗口的标题框。
- 修复“更多”的文字与菜单箭头重叠;正常宽度下两者并排,极窄屏自动保留箭头菜单入口,屏幕恢复后显示文字。
- 工具跟随所属 DxDesigner 窗口:DX 最小化时隐藏工具栏和面板,DX 恢复时还原此前的展开或收起状态,并保留表单输入。隐藏期间选择监听和导出继续运行;恢复工具不会抢走 DX 焦点。
- 关闭所属 DxDesigner 时,工具自动退出,同时关闭工具栏、面板和后台监听;展开、收起或随 DX 隐藏时均生效。关闭其他 DX 窗口不会退出当前工具。
- 如果 DxDesigner 还停在 Start Page、没有打开工程和活动原理图页,菜单动作会直接提示“请先打开工程并进入原理图页后再使用工具”,不再显示原生 131 集合错误。
- 收起后工具栏继续显示选择与任务状态;悬停可查看完整位号、工程、图页和状态信息。拖动左侧手柄移动,位置与各页面大小会保存。
- 页面移除固定左导航、重复标题与说明,操作按钮移到对应页面。低频设置折叠为高级选项,并显示当前有效参数摘要。
@@ -86,5 +86,10 @@ class HostWindowWatcher(QObject):
self.host = self._read_host(self.selection_path)
if self.host is not None:
minimized = self.backend.is_minimized(self.host)
if minimized is not None:
self.window.set_host_minimized(minimized)
if minimized is None:
# The exact owning DX window disappeared. Close the tool via
# the normal shutdown path so controllers and listeners stop.
if self.window.request_exit():
self.timer.stop()
return
self.window.set_host_minimized(minimized)
+51
View File
@@ -131,6 +131,57 @@ def test_watcher_follows_exact_bridge_host_even_during_transaction(qtbot, tmp_pa
assert not watcher.timer.isActive()
@pytest.mark.parametrize('expanded', (False, True))
@pytest.mark.parametrize('minimized', (False, True))
def test_watcher_exits_tool_when_owned_dx_window_disappears(qtbot, tmp_path, expanded, minimized):
from dx_productivity.ui.host_window_watcher import HostWindowWatcher
window = MainWindow(layout_path=tmp_path / 'layout.json')
qtbot.addWidget(window)
window.refdes_controller = SimpleNamespace(snapshot=SimpleNamespace(run_id='run-1', design_path='C:/demo.prj'))
request = tmp_path / 'request.json'
request.write_text(json.dumps({'run_id': 'run-1', 'design_path': 'C:/demo.prj', 'host_view_handle': 100}), encoding='utf-8')
backend = FakeHostWindows()
watcher = HostWindowWatcher(window, request, backend=backend)
window.show_panel(0) if expanded else window.show_toolbar()
backend.minimized.pop(200)
watcher._check()
assert not window._closing and watcher.timer.isActive()
assert window.toolbar.isVisible() and window.isVisible() is expanded
backend.minimized[100] = minimized
watcher._check()
backend.minimized.pop(100)
watcher._check()
assert window._closing
assert not window.toolbar.isVisible() and not window.isVisible()
assert not watcher.timer.isActive()
def test_watcher_retries_host_close_after_menu_registration_finishes(qtbot, tmp_path):
from dx_productivity.ui.host_window_watcher import HostWindowWatcher
window = MainWindow(layout_path=tmp_path / 'layout.json')
qtbot.addWidget(window)
window.refdes_controller = SimpleNamespace(snapshot=SimpleNamespace(run_id='run-1', design_path='C:/demo.prj'))
request = tmp_path / 'request.json'
request.write_text(json.dumps({'run_id': 'run-1', 'design_path': 'C:/demo.prj', 'host_view_handle': 100}), encoding='utf-8')
backend = FakeHostWindows()
watcher = HostWindowWatcher(window, request, backend=backend)
window.show_toolbar()
registering = [True]
window.startup_controller = SimpleNamespace(is_running=lambda: registering[0])
backend.minimized.pop(100)
watcher._check()
assert not window._closing and watcher.timer.isActive()
registering[0] = False
qtbot.waitUntil(lambda: window._closing)
assert not window.toolbar.isVisible() and not watcher.timer.isActive()
def test_watcher_can_bind_later_from_selection_without_using_foreign_run(qtbot, tmp_path):
from dx_productivity.ui.host_window_watcher import HostWindowWatcher