mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-06 07:38:21 +00:00
macos: just some textual cleanup
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// C imports here are exposed to Swift.
|
||||
|
||||
#import "VibrantLayer.h"
|
||||
#import "ObjCExceptionCatcher.h"
|
||||
#import "VibrantLayer.h"
|
||||
|
||||
@@ -41,7 +41,8 @@ extension NSWindow {
|
||||
}
|
||||
|
||||
/// Wraps `addTabbedWindow` with an Objective-C exception catcher because AppKit can
|
||||
/// occasionally throw NSExceptions in visual tab picker flows.
|
||||
/// throw NSExceptions in visual tab picker flows. Swift cannot safely recover from
|
||||
/// those exceptions, so we route through Obj-C and log a recoverable failure.
|
||||
@discardableResult
|
||||
func addTabbedWindowSafely(
|
||||
_ child: NSWindow,
|
||||
@@ -49,10 +50,8 @@ extension NSWindow {
|
||||
) -> Bool {
|
||||
var error: NSError?
|
||||
let success = GhosttyAddTabbedWindowSafely(self, child, ordered.rawValue, &error)
|
||||
|
||||
if let error {
|
||||
let reason = error.localizedDescription
|
||||
Ghostty.logger.error("addTabbedWindow failed: \(reason)")
|
||||
Ghostty.logger.error("addTabbedWindow failed: \(error.localizedDescription)")
|
||||
}
|
||||
|
||||
return success
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/// Minimal Objective-C exception bridge for AppKit tabbing APIs.
|
||||
/// This file contains wrappers around various ObjC functions so we can catch
|
||||
/// exceptions, since you can't natively catch ObjC exceptions from Swift
|
||||
/// (at least at the time of writing this comment).
|
||||
|
||||
/// NSWindow.addTabbedWindow wrapper
|
||||
FOUNDATION_EXPORT BOOL GhosttyAddTabbedWindowSafely(
|
||||
id parent,
|
||||
id child,
|
||||
id _Nonnull parent,
|
||||
id _Nonnull child,
|
||||
NSInteger ordered,
|
||||
NSError * _Nullable * _Nullable error
|
||||
);
|
||||
|
||||
@@ -12,6 +12,8 @@ BOOL GhosttyAddTabbedWindowSafely(
|
||||
NSError * _Nullable * _Nullable error
|
||||
) {
|
||||
#if TARGET_OS_OSX
|
||||
// AppKit occasionally throws NSException while reparenting tabbed windows.
|
||||
// We must catch it in Objective-C; letting this cross into Swift is unsafe.
|
||||
@try {
|
||||
[((NSWindow *)parent) addTabbedWindow:(NSWindow *)child ordered:(NSWindowOrderingMode)ordered];
|
||||
return YES;
|
||||
|
||||
Reference in New Issue
Block a user