Skip to content

Commit 8362d9b

Browse files
authored
fix: prevent AppKit button metrics crash on macOS 26 (#1201)
1 parent da91cd9 commit 8362d9b

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎Sources/OpenSwiftUI/View/Control/Button/AppKitButton.swift‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,29 @@ extension NSButton {
458458
var content = NSEdgeInsetsZero
459459
Update.syncMain {
460460
if isBordered {
461+
#if OPENSWIFTUI_ATTRIBUTEGRAPH
462+
if #available(macOS 26.0, *) {
463+
// AppKit's Amber support reads system SwiftUI attributes on macOS 26+.
464+
// OpenSwiftUI uses a separate AG namespace, so suspend dependency
465+
// tracking during this call to avoid a cross-namespace input.
466+
Graph.withoutUpdate {
467+
_ = _getIntrinsicArtworkSize(
468+
&size, alignmentRectInsets: &alignment,
469+
idealContentInsets: &content, maxContentInsets: nil
470+
)
471+
}
472+
} else {
473+
_ = _getIntrinsicArtworkSize(
474+
&size, alignmentRectInsets: &alignment,
475+
idealContentInsets: &content, maxContentInsets: nil
476+
)
477+
}
478+
#else
461479
_ = _getIntrinsicArtworkSize(
462480
&size, alignmentRectInsets: &alignment,
463481
idealContentInsets: &content, maxContentInsets: nil
464482
)
483+
#endif
465484
}
466485
}
467486
let alignmentInsets = EdgeInsets(top: alignment.top, leading: alignment.left, bottom: alignment.bottom, trailing: alignment.right)

0 commit comments

Comments
 (0)