Skip to content

fix: 修复 Tauri RPC 子进程死锁及窗口关闭后 QTimer RuntimeError - #141

Open
Ohana986 wants to merge 3 commits into
Rvosy:devfrom
Ohana986:fix/qtimer-context
Open

Ohana986 wants to merge 3 commits into
Rvosy:devfrom
Ohana986:fix/qtimer-context

Conversation

@Ohana986

Copy link
Copy Markdown
Contributor

fix: 修复 Tauri RPC 子进程死锁及窗口关闭后 QTimer RuntimeError

改动内容

包含 3 个 commit,解决两个问题:

1. Tauri RPC 子线程 stdin 死锁(f9022bd)

Rust 子线程通过 std::io::stdin() 读取 RPC 响应时,与主线程 BufReader 共用同一 fd 0,
触发全局内部 Mutex 死锁。

修复: Python 侧创建独立 pipe 作为 RPC 响应通道,通过 SAKURA_RPC_RESPONSE_FD 环境变量
传递给子进程;Rust 侧从该 fd 读取响应,绕过 stdin 的全局锁。

涉及文件:

  • app/ui/tauri_settings.py — 新增 pipe 创建、异常安全清理、写入通道切换
  • tools/settings-tauri/src-tauri/src/lib.rs — 新增 #[cfg(unix)] 分叉读取逻辑,
    移除 #[cfg(not(unix))] 中的内部重复 BufReader
  • main.py — 新增 socks://socks5:// 代理 scheme 规范化

2. QTimer.singleShot 窗口关闭后触发 RuntimeError(57af702)

QTimer.singleShot(delay, callback) 在窗口销毁后仍会触发回调,此时访问已销毁的
QObject 会抛出 RuntimeError。

修复: 改为三参数形式 QTimer.singleShot(delay, self, callback),将 QTimer
的生命周期绑定到 receiver 对象,窗口关闭后自动取消未触发的定时器。

涉及文件:

  • app/ui/tauri_settings.py

兼容性

  • 无配置格式或公开接口变更
  • SAKURA_RPC_RESPONSE_FD 环境变量仅内部使用,不影响用户配置
  • 非 Unix 平台(Windows)行为与原逻辑一致

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.

1 participant