Repository navigation
test(desktop): 修复两个桌面端测试的崩溃与收尾异常 - #1
Open
SolarCrown57 wants to merge 1 commit into
Open
SolarCrown57 wants to merge 1 commit into
SolarCrown57 wants to merge 1 commit into
Conversation
- test_discard_unsaved_edit_reopens_from_formally_saved_subtitle: 构造第二个窗口时用 patch.object 替换 DesktopWindow 类属性 _start_waveform, 在已有窗口存活时会让 PySide 在 _appbar 设置图标处 access violation,用例稳定崩溃; 且该 patch 只在构造期间生效,拦不到异步载入后才发生的调用。 改为构造后在实例上替换,并由 addCleanup 覆盖整个用例。 - test_explicit_seek_ignores_stale_player_position_and_playing_highlight: FakePlayer 缺少 close(),收尾关窗时 closeEvent 调用 player.close() 抛出 AttributeError, 后续 Qt 事件再进入 Python 重写时处于异常状态;补一个空的 close()。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
修复
desktop-vnext-dev新增桌面端测试中的两个问题:一条用例稳定崩溃,一条用例收尾时抛异常。只改测试文件,不改业务代码。问题与修复
1.
test_discard_unsaved_edit_reopens_from_formally_saved_subtitle稳定崩溃DesktopWindow时进程 access violation,崩在_appbar给按钮设置图标那一行。整轮unittest会在这里中断,后面的用例都跑不到。patch.object(DesktopWindow, "_start_waveform")替换了类属性。第一个窗口还活着时修改 Shiboken 包装类的类属性,会让 PySide 后续回调 Python 时出错。最小复现只需「窗口 A 存活 → patch 类属性 → 构造窗口 B」,和未保存修改、确认框都无关。_start_waveform在异步载入完成后才调用,而 patch 只在构造那一刻有效,调用发生时早已恢复成原方法。_start_waveform,用addCleanup覆盖整个用例。改后确实拦截到了这次调用。2.
test_explicit_seek_ignores_stale_player_position_and_playing_highlight收尾异常closeEvent调用self.player.close(),FakePlayer没有这个方法,抛出AttributeError。此后 Qt 派发的焦点事件会在异常状态下进入 Python 的event()重写。现在只是打印报错,但若再多一层 Python 事件过滤器(例如桌面 UI 分支的动效)就会直接崩溃。FakePlayer补一个空的close()。真实的MpvAdapter本来就有这个方法。验证
本地环境:Windows 11,Python 3.12,PySide6 6.10.1,
QT_QPA_PLATFORM=offscreen。AttributeError。test_playhead_full_height_blank_scrub_and_cue_priority,它在基线13a33d3上就失败,本 PR 未涉及。ruff check tests/unit/test_desktop_render.py通过。注意:CI 没有安装 PySide6,桌面端 Qt 测试在 CI 里会整体跳过,所以这两个问题只能在装了 PySide6 的本地环境复现和验证。
未包含:另一个偶发问题
把全部桌面端测试放在同一个进程里跑时,偶尔会出现
Tcl_AsyncDelete: async handler deleted by the wrong thread并中止进程。原因是test_desktop_app测旧版 Tk 桌面端时创建的 Tk 对象,被后续 Qt 测试的后台线程(项目扫描任务)触发的垃圾回收在非主线程回收了。这和本 PR 的两个问题无关,而且是偶发的,所以没有一起处理。可选方向:让 Tk 测试在收尾时显式销毁并回收,或者把 Tk 和 Qt 的测试分进程运行。🤖 Generated with Claude Code