From dae85e244c2a7d93fee4f8edb250ddc1b4ee88b7 Mon Sep 17 00:00:00 2001 From: heinrich5991 Date: Fri, 17 Nov 2017 14:57:42 +0100 Subject: [PATCH] Stop using deprecated APIs on macOS in server launcher (cherry picked from commit dcbd8197a40dd088a773d1c750ca56f554c8928d) --- src/osxlaunch/server.mm | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/osxlaunch/server.mm b/src/osxlaunch/server.mm index 5ad2d4eda..3135d439c 100644 --- a/src/osxlaunch/server.mm +++ b/src/osxlaunch/server.mm @@ -5,11 +5,11 @@ NSTask *task; NSFileHandle *file; } -- (void)listenTo: (NSTask*)t; +- (void)listenTo: (NSTask *)t; @end @implementation ServerView -- (void)listenTo: (NSTask*)t; +- (void)listenTo: (NSTask *)t { NSPipe *pipe; task = t; @@ -49,24 +49,20 @@ void runServer() { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSApp = [NSApplication sharedApplication]; - NSBundle* mainBundle = [NSBundle mainBundle]; + NSBundle *mainBundle = [NSBundle mainBundle]; NSTask *task; task = [[NSTask alloc] init]; [task setCurrentDirectoryPath: [mainBundle resourcePath]]; // get a server config - NSOpenPanel* openDlg = [NSOpenPanel openPanel]; + NSOpenPanel *openDlg = [NSOpenPanel openPanel]; [openDlg setCanChooseFiles:YES]; - if([openDlg runModalForDirectory:nil file:nil] != NSOKButton) + if([openDlg runModal] != NSOKButton) return; - NSArray* filenames = [openDlg filenames]; - if([filenames count] != 1) - return; - - NSString* filename = [filenames objectAtIndex: 0]; - NSArray* arguments = [NSArray arrayWithObjects: @"-f", filename, nil]; + NSString *filename = [[openDlg URL] path]; + NSArray *arguments = [NSArray arrayWithObjects: @"-f", filename, nil]; // run server NSWindow *window; @@ -104,7 +100,7 @@ void runServer() [pool release]; } -int main (int argc, char **argv) +int main(int argc, char **argv) { runServer();