Fix exclusive-access crash in WindowDragHandleView hitTest (#736)

Add early return for non-leftMouseDown events in DraggableView.hitTest
to prevent re-entering SwiftUI view state during mouseMoved layout
passes, which caused fatal exclusive-access violations.
This commit is contained in:
Haruki Tosa 2026-03-02 14:38:23 +09:00 committed by GitHub
parent 33242f8780
commit c6e8d8484b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -359,6 +359,13 @@ struct WindowDragHandleView: NSViewRepresentable {
override func hitTest(_ point: NSPoint) -> NSView? {
let currentEvent = NSApp.currentEvent
// Fast bail-out: only claim hits for left-mouse-down events.
// For mouseMoved / mouseEntered / etc., return nil immediately
// to avoid re-entering SwiftUI view state during layout passes,
// which causes exclusive-access crashes.
guard currentEvent?.type == .leftMouseDown else {
return nil
}
let shouldCapture = windowDragHandleShouldCaptureHit(
point,
in: self,