Skip to content

fix(macos): stop_qa_hotkey_listener 包 run_on_main_thread (closes #169)#174

Merged
appergb merged 1 commit into
mainfrom
fix/issue-169-macos-exit-main-thread
May 2, 2026
Merged

fix(macos): stop_qa_hotkey_listener 包 run_on_main_thread (closes #169)#174
appergb merged 1 commit into
mainfrom
fix/issue-169-macos-exit-main-thread

Conversation

@appergb
Copy link
Copy Markdown
Collaborator

@appergb appergb commented May 2, 2026

摘要

Closes #169

QaHotkeyMonitor drop 在 macOS 调 Carbon RemoveEventHotKey 要求主线程。`RunEvent::Exit` 不保证主线程 → drop 漏到 tokio worker → SIGTRAP。

修复

`coordinator.rs::stop_qa_hotkey_listener` 把 `.take()` 包到 `run_on_main_thread`;`AppHandle` None 时直接 drop(极端 shutdown 兜底)。

测试

  • `cargo check` ✅

@codex review。

QaHotkeyMonitor::drop 在 macOS 底层调 Carbon RemoveEventHotKey,要求主线程。
RunEvent::Exit 回调不保证在 AppKit 主线程跑——drop 漏到 tokio worker 上
触发 macOS dispatch_assert_queue_fail SIGTRAP,退出时偶发崩溃。

修:
- coordinator.rs::stop_qa_hotkey_listener 把 .take() 包到 run_on_main_thread
- AppHandle 已 None 时(极端 shutdown 序)直接 drop 兜底(最坏崩也是退出时机)

测试:
- cargo check ✅
Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @appergb, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@appergb appergb merged commit fcd37fb into main May 2, 2026
2 checks passed
@appergb appergb deleted the fix/issue-169-macos-exit-main-thread branch May 2, 2026 02:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[macos] 退出时 QaHotkeyMonitor drop 在非主线程,Carbon API 触发 SIGTRAP 风险

1 participant