Repository navigation
修复:关闭贴图时进程闪退 - #27
Merged
Merged
修复:关闭贴图时进程闪退#27
Conversation
贴图窗口建好时 WKWebView 已在窗口上挂了 KVO,之后 from_window 用 object_setClass 换成 NSPanel; destroy 拆 webview 时 WebKit 按新类注销 KVO 对不上,抛 NSRangeException,panic=abort 下整个进程退出。 换类前按贴图序号记下原来的类,关闭时在主线程先换回再销毁;类在此期间又变了就只隐藏不销毁。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Merged
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.
问题
v0.5.2 关闭贴图(双击 / Esc / 右键“关闭”)时进程 SIGABRT 退出。崩溃报告:
-[NSWindow removeObserver:forKeyPath:]抛NSRangeException(contentLayoutRect观察者未注册),调用自WKWindowVisibilityObserver stopObserving←removeFromSuperview;应用日志里崩溃时刻正好是shot 关闭贴图 1。原因
贴图窗口建好时 WKWebView 已在窗口上挂 KVO(类变成
NSKVONotifying_TaoWindow),show_pin随后用RawNSPanel::from_window做object_setClass;销毁时 WebKit 按新类注销 KVO 对不上,抛异常,panic=abort下整个进程退出。主面板、截图遮罩、翻译卡片、录屏边框也换过类,但从不销毁(含退出时),不受影响。最小 Swift 复现(NSWindow 子类 + WKWebView → object_setClass 成 NSPanel 子类 → removeFromSuperview)得到同一个异常与调用栈;销毁前把类换回去则正常。
修复
show_pin换类前按贴图序号记下原来的类;pin_close在主线程先换回再destroy。若期间窗口类又变了(换类后又被挂 KVO),只隐藏不销毁,避免第二种崩溃。验收
make check🤖 Generated with Claude Code