Remove Cocoa spam from the SDL port

This commit is contained in:
Lior Halphon 2021-09-09 00:11:49 +03:00
parent d8a9f12a4f
commit 336bc65dbf
1 changed files with 6 additions and 0 deletions

View File

@ -5,6 +5,8 @@
char *do_open_rom_dialog(void) char *do_open_rom_dialog(void)
{ {
@autoreleasepool { @autoreleasepool {
int stderr_fd = dup(STDERR_FILENO);
close(STDERR_FILENO);
NSWindow *key = [NSApp keyWindow]; NSWindow *key = [NSApp keyWindow];
NSOpenPanel *dialog = [NSOpenPanel openPanel]; NSOpenPanel *dialog = [NSOpenPanel openPanel];
dialog.title = @"Open ROM"; dialog.title = @"Open ROM";
@ -12,6 +14,7 @@ char *do_open_rom_dialog(void)
[dialog runModal]; [dialog runModal];
[key makeKeyAndOrderFront:nil]; [key makeKeyAndOrderFront:nil];
NSString *ret = [[[dialog URLs] firstObject] path]; NSString *ret = [[[dialog URLs] firstObject] path];
dup2(stderr_fd, STDERR_FILENO);
if (ret) { if (ret) {
return strdup(ret.UTF8String); return strdup(ret.UTF8String);
} }
@ -22,6 +25,8 @@ char *do_open_rom_dialog(void)
char *do_open_folder_dialog(void) char *do_open_folder_dialog(void)
{ {
@autoreleasepool { @autoreleasepool {
int stderr_fd = dup(STDERR_FILENO);
close(STDERR_FILENO);
NSWindow *key = [NSApp keyWindow]; NSWindow *key = [NSApp keyWindow];
NSOpenPanel *dialog = [NSOpenPanel openPanel]; NSOpenPanel *dialog = [NSOpenPanel openPanel];
dialog.title = @"Select Boot ROMs Folder"; dialog.title = @"Select Boot ROMs Folder";
@ -30,6 +35,7 @@ char *do_open_folder_dialog(void)
[dialog runModal]; [dialog runModal];
[key makeKeyAndOrderFront:nil]; [key makeKeyAndOrderFront:nil];
NSString *ret = [[[dialog URLs] firstObject] path]; NSString *ret = [[[dialog URLs] firstObject] path];
dup2(stderr_fd, STDERR_FILENO);
if (ret) { if (ret) {
return strdup(ret.UTF8String); return strdup(ret.UTF8String);
} }