fix(windows-ime): 移除 DisableThreadLibraryCalls — /MT 下需 thread 通知

Codex P1 (PR #287):DLL 改用 /MT 静态链接 CRT 后,仍调
DisableThreadLibraryCalls(instance) 会让静态 CRT 拿不到 DLL_THREAD_DETACH
通知,per-thread TLS 初始化/清理断裂 — 在 host 进程(QQ / Office /
微软拼音切换)创建新 input thread 时反而把这次想修的崩溃问题重新引回。

Microsoft 文档 DisableThreadLibraryCalls 备注明确:使用 static CRT 的
DLL 不应禁用 thread library calls。

修复:删除该调用;保留 g_module 缓存。
This commit is contained in:
baiqing committed 2026-05-06 19:07:54 +08:00
1 parent 80de07851c
commit 901e9dfe3f
1 file changed
+5 -1
+5 -1
View File
@@ -13,9 +13,13 @@ LONG g_object_count = 0;
BOOL APIENTRY DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) {
UNREFERENCED_PARAMETER(reserved);
// 不调用 DisableThreadLibraryCalls:DLL 现在用 /MT 静态链接 CRT,CRT 需要
// DLL_THREAD_ATTACH / DLL_THREAD_DETACH 通知做 per-thread TLS 初始化与清理。
// 在 host 进程(如 QQ / Office)切输入法新建 input thread 时禁用通知,会让
// 静态 CRT 的 thread-local 资源泄漏 / 行为不稳定,反而把这次想修的崩溃问题
// 重新引回来。详见 Microsoft 文档 DisableThreadLibraryCalls 备注。
if (reason == DLL_PROCESS_ATTACH) {
g_module = instance;
DisableThreadLibraryCalls(instance);
}
return TRUE;