Skip to content

Commit fa6d28f

Browse files
try(settings): 尝试修正快捷键弹窗协程生命周期(编译通过,待验证) / Try correcting shortcut dialog coroutine lifetime (build passed, validation pending)
中文: - 让快捷键弹窗协程按值持有共享状态,避免 ShowAsync 完成时访问已经失效的引用 - 增加源码契约测试,禁止异步弹窗恢复依赖引用参数 English: - Make the shortcut dialog coroutine own shared state by value so the ShowAsync continuation cannot access an expired reference - Add a source contract test that rejects reference parameters for the asynchronous dialog continuation 验证 / Validation: - scripts/build.bat --reload-shell(Release 构建通过,已生成 .build\\Release\\SnowDesktop.exe / Release build passed and generated .build\\Release\\SnowDesktop.exe) - scripts/test.bat(103/103 通过 / 103/103 passed) 限制 / Limitations: - 修正后的回车应用场景尚待用户实机复测 / The corrected Enter-to-apply scenario still requires user runtime validation
1 parent 0a384bb commit fa6d28f

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

‎src/winui/hotkey_recorder.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ void ApplyTransition(
583583
}
584584

585585
winrt::fire_and_forget ShowShortcutDialog(
586-
const std::shared_ptr<HotkeyRecorderState>& state)
586+
std::shared_ptr<HotkeyRecorderState> state)
587587
{
588588
if (!state || !state->alive || !state->enabled || state->dialogOpen)
589589
co_return;

‎tests/winui_settings_navigation_tests.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,12 @@ void TestGeneralPageSourceContract(const std::filesystem::path& root)
800800
recorder.find(
801801
"dialog.DefaultButton(muxc::ContentDialogButton::Primary)") !=
802802
std::string::npos &&
803+
recorder.find(
804+
"ShowShortcutDialog(\n std::shared_ptr<HotkeyRecorderState> state)") !=
805+
std::string::npos &&
806+
recorder.find(
807+
"ShowShortcutDialog(\n const std::shared_ptr<HotkeyRecorderState>& state)") ==
808+
std::string::npos &&
803809
recorder.find("co_await state->dialog.ShowAsync()") !=
804810
std::string::npos &&
805811
recorder.find("captureSurface.KeyDown") !=

0 commit comments

Comments
 (0)