[macOS] Enable Objective-C ARC

This commit is contained in:
bruvzg 2022-01-25 10:07:01 +02:00
parent ea12094f19
commit 33d6d4bdf7
No known key found for this signature in database
GPG Key ID: 7960FCF39844EC38
7 changed files with 46 additions and 118 deletions

View File

@ -39,7 +39,6 @@
class CameraOSX : public CameraServer { class CameraOSX : public CameraServer {
public: public:
CameraOSX(); CameraOSX();
~CameraOSX();
void update_feeds(); void update_feeds();
}; };

View File

@ -114,18 +114,12 @@
if (output) { if (output) {
[self removeOutput:output]; [self removeOutput:output];
[output setSampleBufferDelegate:nil queue:nullptr]; [output setSampleBufferDelegate:nil queue:nullptr];
[output release];
output = nullptr; output = nullptr;
} }
[self commitConfiguration]; [self commitConfiguration];
} }
- (void)dealloc {
// bye bye
[super dealloc];
}
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection { - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
// This gets called every time our camera has a new image for us to process. // This gets called every time our camera has a new image for us to process.
// May need to investigate in a way to throttle this if we get more images then we're rendering frames.. // May need to investigate in a way to throttle this if we get more images then we're rendering frames..
@ -208,7 +202,6 @@ public:
AVCaptureDevice *get_device() const; AVCaptureDevice *get_device() const;
CameraFeedOSX(); CameraFeedOSX();
~CameraFeedOSX();
void set_device(AVCaptureDevice *p_device); void set_device(AVCaptureDevice *p_device);
@ -227,7 +220,6 @@ CameraFeedOSX::CameraFeedOSX() {
void CameraFeedOSX::set_device(AVCaptureDevice *p_device) { void CameraFeedOSX::set_device(AVCaptureDevice *p_device) {
device = p_device; device = p_device;
[device retain];
// get some info // get some info
NSString *device_name = p_device.localizedName; NSString *device_name = p_device.localizedName;
@ -240,18 +232,6 @@ void CameraFeedOSX::set_device(AVCaptureDevice *p_device) {
}; };
}; };
CameraFeedOSX::~CameraFeedOSX() {
if (capture_session != nullptr) {
[capture_session release];
capture_session = nullptr;
};
if (device != nullptr) {
[device release];
device = nullptr;
};
};
bool CameraFeedOSX::activate_feed() { bool CameraFeedOSX::activate_feed() {
if (capture_session) { if (capture_session) {
// Already recording! // Already recording!
@ -282,7 +262,6 @@ void CameraFeedOSX::deactivate_feed() {
// end camera capture if we have one // end camera capture if we have one
if (capture_session) { if (capture_session) {
[capture_session cleanup]; [capture_session cleanup];
[capture_session release];
capture_session = nullptr; capture_session = nullptr;
}; };
}; };
@ -317,8 +296,6 @@ void CameraFeedOSX::deactivate_feed() {
// remove notifications // remove notifications
[[NSNotificationCenter defaultCenter] removeObserver:self name:AVCaptureDeviceWasConnectedNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:AVCaptureDeviceWasConnectedNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:AVCaptureDeviceWasDisconnectedNotification object:nil]; [[NSNotificationCenter defaultCenter] removeObserver:self name:AVCaptureDeviceWasDisconnectedNotification object:nil];
[super dealloc];
} }
@end @end
@ -376,7 +353,3 @@ CameraOSX::CameraOSX() {
// should only have one of these.... // should only have one of these....
device_notifications = [[MyDeviceNotifications alloc] initForServer:this]; device_notifications = [[MyDeviceNotifications alloc] initForServer:this];
}; };
CameraOSX::~CameraOSX() {
[device_notifications release];
};

View File

@ -86,6 +86,8 @@ def configure(env):
env.Append(CCFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"]) env.Append(CCFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"])
env.Append(LINKFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"]) env.Append(LINKFLAGS=["-arch", "x86_64", "-mmacosx-version-min=10.12"])
env.Append(CCFLAGS=["-fobjc-arc"])
if not "osxcross" in env: # regular native build if not "osxcross" in env: # regular native build
if env["macports_clang"] != "no": if env["macports_clang"] != "no":
mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local") mpprefix = os.environ.get("MACPORTS_PREFIX", "/opt/local")

View File

@ -167,7 +167,6 @@ public:
String rendering_driver; String rendering_driver;
id autoreleasePool;
CGEventSourceRef eventSource; CGEventSourceRef eventSource;
CursorShape cursor_shape; CursorShape cursor_shape;

View File

@ -439,12 +439,6 @@ static NSCursor *_cursorFromSelector(SEL selector, SEL fallback = nil) {
return self; return self;
} }
- (void)dealloc {
[trackingArea release];
[markedText release];
[super dealloc];
}
static const NSRange kEmptyRange = { NSNotFound, 0 }; static const NSRange kEmptyRange = { NSNotFound, 0 };
- (BOOL)hasMarkedText { - (BOOL)hasMarkedText {
@ -461,9 +455,9 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
- (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange { - (void)setMarkedText:(id)aString selectedRange:(NSRange)selectedRange replacementRange:(NSRange)replacementRange {
if ([aString isKindOfClass:[NSAttributedString class]]) { if ([aString isKindOfClass:[NSAttributedString class]]) {
[markedText initWithAttributedString:aString]; markedText = [markedText initWithAttributedString:aString];
} else { } else {
[markedText initWithString:aString]; markedText = [markedText initWithString:aString];
} }
if (markedText.length == 0) { if (markedText.length == 0) {
[self unmarkText]; [self unmarkText];
@ -482,12 +476,6 @@ static const NSRange kEmptyRange = { NSNotFound, 0 };
} }
} }
- (void)doCommandBySelector:(SEL)aSelector {
if ([self respondsToSelector:aSelector]) {
[self performSelector:aSelector];
}
}
- (void)unmarkText { - (void)unmarkText {
imeInputEventInProgress = false; imeInputEventInProgress = false;
[[markedText mutableString] setString:@""]; [[markedText mutableString] setString:@""];
@ -875,7 +863,6 @@ static void _mouseDownEvent(DisplayServer::WindowID window_id, NSEvent *event, M
- (void)updateTrackingAreas { - (void)updateTrackingAreas {
if (trackingArea != nil) { if (trackingArea != nil) {
[self removeTrackingArea:trackingArea]; [self removeTrackingArea:trackingArea];
[trackingArea release];
} }
NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited | NSTrackingActiveInKeyWindow | NSTrackingCursorUpdate | NSTrackingInVisibleRect; NSTrackingAreaOptions options = NSTrackingMouseEnteredAndExited | NSTrackingActiveInKeyWindow | NSTrackingCursorUpdate | NSTrackingInVisibleRect;
@ -1544,7 +1531,7 @@ void DisplayServerOSX::global_menu_add_item(const String &p_menu_root, const Str
NSMenu *menu = _get_menu_root(p_menu_root); NSMenu *menu = _get_menu_root(p_menu_root);
if (menu) { if (menu) {
NSMenuItem *menu_item = [menu addItemWithTitle:[NSString stringWithUTF8String:p_label.utf8().get_data()] action:@selector(globalMenuCallback:) keyEquivalent:@""]; NSMenuItem *menu_item = [menu addItemWithTitle:[NSString stringWithUTF8String:p_label.utf8().get_data()] action:@selector(globalMenuCallback:) keyEquivalent:@""];
GlobalMenuItem *obj = [[[GlobalMenuItem alloc] init] autorelease]; GlobalMenuItem *obj = [[GlobalMenuItem alloc] init];
obj->callback = p_callback; obj->callback = p_callback;
obj->meta = p_tag; obj->meta = p_tag;
obj->checkable = false; obj->checkable = false;
@ -1558,7 +1545,7 @@ void DisplayServerOSX::global_menu_add_check_item(const String &p_menu_root, con
NSMenu *menu = _get_menu_root(p_menu_root); NSMenu *menu = _get_menu_root(p_menu_root);
if (menu) { if (menu) {
NSMenuItem *menu_item = [menu addItemWithTitle:[NSString stringWithUTF8String:p_label.utf8().get_data()] action:@selector(globalMenuCallback:) keyEquivalent:@""]; NSMenuItem *menu_item = [menu addItemWithTitle:[NSString stringWithUTF8String:p_label.utf8().get_data()] action:@selector(globalMenuCallback:) keyEquivalent:@""];
GlobalMenuItem *obj = [[[GlobalMenuItem alloc] init] autorelease]; GlobalMenuItem *obj = [[GlobalMenuItem alloc] init];
obj->callback = p_callback; obj->callback = p_callback;
obj->meta = p_tag; obj->meta = p_tag;
obj->checkable = true; obj->checkable = true;
@ -1869,7 +1856,6 @@ Error DisplayServerOSX::dialog_show(String p_title, String p_description, Vector
p_callback.call((const Variant **)&buttonp, 1, ret, ce); p_callback.call((const Variant **)&buttonp, 1, ret, ce);
} }
[window release];
return OK; return OK;
} }
@ -1904,7 +1890,6 @@ Error DisplayServerOSX::dialog_input_text(String p_title, String p_description,
p_callback.call((const Variant **)&textp, 1, ret, ce); p_callback.call((const Variant **)&textp, 1, ret, ce);
} }
[window release];
return OK; return OK;
} }
@ -3059,7 +3044,6 @@ void DisplayServerOSX::cursor_set_custom_image(const RES &p_cursor, CursorShape
NSCursor *cursor = [[NSCursor alloc] initWithImage:nsimage hotSpot:NSMakePoint(p_hotspot.x, p_hotspot.y)]; NSCursor *cursor = [[NSCursor alloc] initWithImage:nsimage hotSpot:NSMakePoint(p_hotspot.x, p_hotspot.y)];
[cursors[p_shape] release];
cursors[p_shape] = cursor; cursors[p_shape] = cursor;
Vector<Variant> params; Vector<Variant> params;
@ -3072,13 +3056,9 @@ void DisplayServerOSX::cursor_set_custom_image(const RES &p_cursor, CursorShape
[cursor set]; [cursor set];
} }
} }
[imgrep release];
[nsimage release];
} else { } else {
// Reset to default system cursor // Reset to default system cursor
if (cursors[p_shape] != nullptr) { if (cursors[p_shape] != nullptr) {
[cursors[p_shape] release];
cursors[p_shape] = nullptr; cursors[p_shape] = nullptr;
} }
@ -3105,46 +3085,42 @@ static void keyboard_layout_changed(CFNotificationCenterRef center, void *observ
} }
void _update_keyboard_layouts() { void _update_keyboard_layouts() {
@autoreleasepool { TISInputSourceRef cur_source = TISCopyCurrentKeyboardInputSource();
TISInputSourceRef cur_source = TISCopyCurrentKeyboardInputSource(); NSString *cur_name = (__bridge NSString *)TISGetInputSourceProperty(cur_source, kTISPropertyLocalizedName);
NSString *cur_name = (NSString *)TISGetInputSourceProperty(cur_source, kTISPropertyLocalizedName); CFRelease(cur_source);
CFRelease(cur_source);
// Enum IME layouts // Enum IME layouts
NSDictionary *filter_ime = @{ (NSString *)kTISPropertyInputSourceType : (NSString *)kTISTypeKeyboardInputMode }; NSDictionary *filter_ime = @{ (NSString *)kTISPropertyInputSourceType : (NSString *)kTISTypeKeyboardInputMode };
NSArray *list_ime = (NSArray *)TISCreateInputSourceList((CFDictionaryRef)filter_ime, false); NSArray *list_ime = (__bridge NSArray *)TISCreateInputSourceList((__bridge CFDictionaryRef)filter_ime, false);
for (NSUInteger i = 0; i < [list_ime count]; i++) { for (NSUInteger i = 0; i < [list_ime count]; i++) {
LayoutInfo ly; LayoutInfo ly;
NSString *name = (NSString *)TISGetInputSourceProperty((TISInputSourceRef)[list_ime objectAtIndex:i], kTISPropertyLocalizedName); NSString *name = (__bridge NSString *)TISGetInputSourceProperty((__bridge TISInputSourceRef)[list_ime objectAtIndex:i], kTISPropertyLocalizedName);
ly.name.parse_utf8([name UTF8String]); ly.name.parse_utf8([name UTF8String]);
NSArray *langs = (NSArray *)TISGetInputSourceProperty((TISInputSourceRef)[list_ime objectAtIndex:i], kTISPropertyInputSourceLanguages); NSArray *langs = (__bridge NSArray *)TISGetInputSourceProperty((__bridge TISInputSourceRef)[list_ime objectAtIndex:i], kTISPropertyInputSourceLanguages);
ly.code.parse_utf8([(NSString *)[langs objectAtIndex:0] UTF8String]); ly.code.parse_utf8([(NSString *)[langs objectAtIndex:0] UTF8String]);
kbd_layouts.push_back(ly); kbd_layouts.push_back(ly);
if ([name isEqualToString:cur_name]) { if ([name isEqualToString:cur_name]) {
current_layout = kbd_layouts.size() - 1; current_layout = kbd_layouts.size() - 1;
}
} }
[list_ime release]; }
// Enum plain keyboard layouts // Enum plain keyboard layouts
NSDictionary *filter_kbd = @{ (NSString *)kTISPropertyInputSourceType : (NSString *)kTISTypeKeyboardLayout }; NSDictionary *filter_kbd = @{ (NSString *)kTISPropertyInputSourceType : (NSString *)kTISTypeKeyboardLayout };
NSArray *list_kbd = (NSArray *)TISCreateInputSourceList((CFDictionaryRef)filter_kbd, false); NSArray *list_kbd = (__bridge NSArray *)TISCreateInputSourceList((__bridge CFDictionaryRef)filter_kbd, false);
for (NSUInteger i = 0; i < [list_kbd count]; i++) { for (NSUInteger i = 0; i < [list_kbd count]; i++) {
LayoutInfo ly; LayoutInfo ly;
NSString *name = (NSString *)TISGetInputSourceProperty((TISInputSourceRef)[list_kbd objectAtIndex:i], kTISPropertyLocalizedName); NSString *name = (__bridge NSString *)TISGetInputSourceProperty((__bridge TISInputSourceRef)[list_kbd objectAtIndex:i], kTISPropertyLocalizedName);
ly.name.parse_utf8([name UTF8String]); ly.name.parse_utf8([name UTF8String]);
NSArray *langs = (NSArray *)TISGetInputSourceProperty((TISInputSourceRef)[list_kbd objectAtIndex:i], kTISPropertyInputSourceLanguages); NSArray *langs = (__bridge NSArray *)TISGetInputSourceProperty((__bridge TISInputSourceRef)[list_kbd objectAtIndex:i], kTISPropertyInputSourceLanguages);
ly.code.parse_utf8([(NSString *)[langs objectAtIndex:0] UTF8String]); ly.code.parse_utf8([(NSString *)[langs objectAtIndex:0] UTF8String]);
kbd_layouts.push_back(ly); kbd_layouts.push_back(ly);
if ([name isEqualToString:cur_name]) { if ([name isEqualToString:cur_name]) {
current_layout = kbd_layouts.size() - 1; current_layout = kbd_layouts.size() - 1;
}
} }
[list_kbd release];
} }
keyboard_layout_dirty = false; keyboard_layout_dirty = false;
@ -3167,26 +3143,24 @@ void DisplayServerOSX::keyboard_set_current_layout(int p_index) {
NSString *cur_name = [NSString stringWithUTF8String:kbd_layouts[p_index].name.utf8().get_data()]; NSString *cur_name = [NSString stringWithUTF8String:kbd_layouts[p_index].name.utf8().get_data()];
NSDictionary *filter_kbd = @{ (NSString *)kTISPropertyInputSourceType : (NSString *)kTISTypeKeyboardLayout }; NSDictionary *filter_kbd = @{ (NSString *)kTISPropertyInputSourceType : (NSString *)kTISTypeKeyboardLayout };
NSArray *list_kbd = (NSArray *)TISCreateInputSourceList((CFDictionaryRef)filter_kbd, false); NSArray *list_kbd = (__bridge NSArray *)TISCreateInputSourceList((__bridge CFDictionaryRef)filter_kbd, false);
for (NSUInteger i = 0; i < [list_kbd count]; i++) { for (NSUInteger i = 0; i < [list_kbd count]; i++) {
NSString *name = (NSString *)TISGetInputSourceProperty((TISInputSourceRef)[list_kbd objectAtIndex:i], kTISPropertyLocalizedName); NSString *name = (__bridge NSString *)TISGetInputSourceProperty((__bridge TISInputSourceRef)[list_kbd objectAtIndex:i], kTISPropertyLocalizedName);
if ([name isEqualToString:cur_name]) { if ([name isEqualToString:cur_name]) {
TISSelectInputSource((TISInputSourceRef)[list_kbd objectAtIndex:i]); TISSelectInputSource((__bridge TISInputSourceRef)[list_kbd objectAtIndex:i]);
break; break;
} }
} }
[list_kbd release];
NSDictionary *filter_ime = @{ (NSString *)kTISPropertyInputSourceType : (NSString *)kTISTypeKeyboardInputMode }; NSDictionary *filter_ime = @{ (NSString *)kTISPropertyInputSourceType : (NSString *)kTISTypeKeyboardInputMode };
NSArray *list_ime = (NSArray *)TISCreateInputSourceList((CFDictionaryRef)filter_ime, false); NSArray *list_ime = (__bridge NSArray *)TISCreateInputSourceList((__bridge CFDictionaryRef)filter_ime, false);
for (NSUInteger i = 0; i < [list_ime count]; i++) { for (NSUInteger i = 0; i < [list_ime count]; i++) {
NSString *name = (NSString *)TISGetInputSourceProperty((TISInputSourceRef)[list_ime objectAtIndex:i], kTISPropertyLocalizedName); NSString *name = (__bridge NSString *)TISGetInputSourceProperty((__bridge TISInputSourceRef)[list_ime objectAtIndex:i], kTISPropertyLocalizedName);
if ([name isEqualToString:cur_name]) { if ([name isEqualToString:cur_name]) {
TISSelectInputSource((TISInputSourceRef)[list_ime objectAtIndex:i]); TISSelectInputSource((__bridge TISInputSourceRef)[list_ime objectAtIndex:i]);
break; break;
} }
} }
[list_ime release];
} }
int DisplayServerOSX::keyboard_get_current_layout() const { int DisplayServerOSX::keyboard_get_current_layout() const {
@ -3383,9 +3357,6 @@ void DisplayServerOSX::process_events() {
} }
} }
} }
[autoreleasePool drain];
autoreleasePool = [[NSAutoreleasePool alloc] init];
} }
void DisplayServerOSX::force_process_and_drop_events() { void DisplayServerOSX::force_process_and_drop_events() {
@ -3408,10 +3379,10 @@ void DisplayServerOSX::set_native_icon(const String &p_filename) {
f->get_buffer((uint8_t *)&data.write[0], len); f->get_buffer((uint8_t *)&data.write[0], len);
memdelete(f); memdelete(f);
NSData *icon_data = [[[NSData alloc] initWithBytes:&data.write[0] length:len] autorelease]; NSData *icon_data = [[NSData alloc] initWithBytes:&data.write[0] length:len];
ERR_FAIL_COND_MSG(!icon_data, "Error reading icon data."); ERR_FAIL_COND_MSG(!icon_data, "Error reading icon data.");
NSImage *icon = [[[NSImage alloc] initWithData:icon_data] autorelease]; NSImage *icon = [[NSImage alloc] initWithData:icon_data];
ERR_FAIL_COND_MSG(!icon, "Error loading icon."); ERR_FAIL_COND_MSG(!icon, "Error loading icon.");
[NSApp setApplicationIconImage:icon]; [NSApp setApplicationIconImage:icon];
@ -3454,9 +3425,6 @@ void DisplayServerOSX::set_icon(const Ref<Image> &p_icon) {
[nsimg addRepresentation:imgrep]; [nsimg addRepresentation:imgrep];
[NSApp setApplicationIconImage:nsimg]; [NSApp setApplicationIconImage:nsimg];
[imgrep release];
[nsimg release];
} }
void DisplayServerOSX::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window) { void DisplayServerOSX::window_set_vsync_mode(DisplayServer::VSyncMode p_vsync_mode, WindowID p_window) {
@ -3720,8 +3688,6 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode
key_event_pos = 0; key_event_pos = 0;
mouse_mode = MOUSE_MODE_VISIBLE; mouse_mode = MOUSE_MODE_VISIBLE;
autoreleasePool = [[NSAutoreleasePool alloc] init];
eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState); eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
ERR_FAIL_COND(!eventSource); ERR_FAIL_COND(!eventSource);
@ -3756,7 +3722,7 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode
dock_menu = [[NSMenu alloc] initWithTitle:@"_dock"]; dock_menu = [[NSMenu alloc] initWithTitle:@"_dock"];
// Setup Apple menu // Setup Apple menu
apple_menu = [[[NSMenu alloc] initWithTitle:@""] autorelease]; apple_menu = [[NSMenu alloc] initWithTitle:@""];
title = [NSString stringWithFormat:NSLocalizedString(@"About %@", nil), nsappname]; title = [NSString stringWithFormat:NSLocalizedString(@"About %@", nil), nsappname];
[apple_menu addItemWithTitle:title action:@selector(showAbout:) keyEquivalent:@""]; [apple_menu addItemWithTitle:title action:@selector(showAbout:) keyEquivalent:@""];
@ -3766,7 +3732,6 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode
menu_item = [apple_menu addItemWithTitle:NSLocalizedString(@"Services", nil) action:nil keyEquivalent:@""]; menu_item = [apple_menu addItemWithTitle:NSLocalizedString(@"Services", nil) action:nil keyEquivalent:@""];
[apple_menu setSubmenu:services forItem:menu_item]; [apple_menu setSubmenu:services forItem:menu_item];
[NSApp setServicesMenu:services]; [NSApp setServicesMenu:services];
[services release];
[apple_menu addItem:[NSMenuItem separatorItem]]; [apple_menu addItem:[NSMenuItem separatorItem]];
@ -3845,14 +3810,6 @@ DisplayServerOSX::DisplayServerOSX(const String &p_rendering_driver, WindowMode
} }
DisplayServerOSX::~DisplayServerOSX() { DisplayServerOSX::~DisplayServerOSX() {
if (dock_menu) {
[dock_menu release];
}
for (Map<String, NSMenu *>::Element *E = submenu.front(); E; E = E->next()) {
[E->get() release];
}
//destroy all windows //destroy all windows
for (Map<WindowID, WindowData>::Element *E = windows.front(); E;) { for (Map<WindowID, WindowData>::Element *E = windows.front(); E;) {
Map<WindowID, WindowData>::Element *F = E; Map<WindowID, WindowData>::Element *F = E;

View File

@ -240,7 +240,7 @@ String OS_OSX::get_unique_id() const {
NSString *serialNumberAsNSString = nil; NSString *serialNumberAsNSString = nil;
if (serialNumberAsCFString) { if (serialNumberAsCFString) {
serialNumberAsNSString = [NSString stringWithString:(NSString *)serialNumberAsCFString]; serialNumberAsNSString = [NSString stringWithString:(__bridge NSString *)serialNumberAsCFString];
CFRelease(serialNumberAsCFString); CFRelease(serialNumberAsCFString);
} }
@ -262,7 +262,6 @@ void OS_OSX::alert(const String &p_alert, const String &p_title) {
id key_window = [[NSApplication sharedApplication] keyWindow]; id key_window = [[NSApplication sharedApplication] keyWindow];
[window runModal]; [window runModal];
[window release];
if (key_window) { if (key_window) {
[key_window makeKeyAndOrderFront:nil]; [key_window makeKeyAndOrderFront:nil];
} }
@ -532,7 +531,6 @@ Error OS_OSX::create_process(const String &p_path, const List<String> &p_argumen
dispatch_semaphore_signal(lock); dispatch_semaphore_signal(lock);
}]; }];
dispatch_semaphore_wait(lock, dispatch_time(DISPATCH_TIME_NOW, 20000000000)); // 20 sec timeout, wait for app to launch. dispatch_semaphore_wait(lock, dispatch_time(DISPATCH_TIME_NOW, 20000000000)); // 20 sec timeout, wait for app to launch.
dispatch_release(lock);
if (err == OK) { if (err == OK) {
if (r_child_id) { if (r_child_id) {
@ -633,7 +631,7 @@ OS_OSX::OS_OSX() {
// finishLaunching below, in order to properly emulate the behavior // finishLaunching below, in order to properly emulate the behavior
// of NSApplicationMain // of NSApplicationMain
NSMenu *main_menu = [[[NSMenu alloc] initWithTitle:@""] autorelease]; NSMenu *main_menu = [[NSMenu alloc] initWithTitle:@""];
[NSApp setMainMenu:main_menu]; [NSApp setMainMenu:main_menu];
[NSApp finishLaunching]; [NSApp finishLaunching];

View File

@ -44,7 +44,7 @@ Error VulkanContextOSX::window_create(DisplayServer::WindowID p_window_id, Displ
createInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK; createInfo.sType = VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK;
createInfo.pNext = nullptr; createInfo.pNext = nullptr;
createInfo.flags = 0; createInfo.flags = 0;
createInfo.pView = p_window; createInfo.pView = (__bridge const void *)p_window;
VkSurfaceKHR surface; VkSurfaceKHR surface;
VkResult err = vkCreateMacOSSurfaceMVK(get_instance(), &createInfo, nullptr, &surface); VkResult err = vkCreateMacOSSurfaceMVK(get_instance(), &createInfo, nullptr, &surface);