From 97b73fd74b734154499d075480496303fab7bc8d Mon Sep 17 00:00:00 2001 From: Rolf Jansen Date: Thu, 17 Sep 2015 22:30:50 -0300 Subject: [PATCH] =?utf8?q?reverted=20change=200c210c8=20from=202015-09-16?= =?utf8?q?=20added=20the=20missing=20part=20for=20opening=20files=20from?= =?utf8?q?=20program=20arguments=20via=20the=20copy=20pipe=20(s.=20commit?= =?utf8?q?=20fd73436=20from=20Alberto=20Garci=CC=81a=20Hierro=20on=202013-?= =?utf8?q?11-01)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- AppKit/NSApplication.h | 3 --- AppKit/NSApplication.m | 37 ++++++++++++++++--------------------- 2 files changed, 16 insertions(+), 24 deletions(-) diff --git a/AppKit/NSApplication.h b/AppKit/NSApplication.h index bec050ce..200ceb3e 100755 --- a/AppKit/NSApplication.h +++ b/AppKit/NSApplication.h @@ -91,8 +91,6 @@ typedef enum { void *_lock; NSMutableArray *_orderedWindows; // get rid of NSTimer *_attentionTimer; - - NSMutableArray *_filesToOpen; } + (NSApplication *)sharedApplication; @@ -205,7 +203,6 @@ typedef enum { - (NSDockTile *)dockTile; // private -- (void)_setFilesToOpen:(NSArray *)filesToOpen; - (void)_addWindow:(NSWindow *)window; - (void)_windowWillBecomeActive:(NSWindow *)window; diff --git a/AppKit/NSApplication.m b/AppKit/NSApplication.m index 29d61086..2e623262 100755 --- a/AppKit/NSApplication.m +++ b/AppKit/NSApplication.m @@ -435,13 +435,6 @@ id NSApp=nil; } else if ([nsOpen isKindOfClass:[NSArray class]]) { openFiles = nsOpen; } - - if (_filesToOpen) - { - [_filesToOpen addObjectsFromArray:openFiles]; - openFiles = _filesToOpen; - } - if ([openFiles count] > 0) { if ([openFiles count] == 1 && [_delegate respondsToSelector: @selector(application:openFile:)]) { @@ -461,8 +454,6 @@ id NSApp=nil; } } [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"NSOpen"]; - [_filesToOpen release]; - _filesToOpen = nil; } return opened; } @@ -1280,10 +1271,6 @@ standardAboutPanel] retain]; [super doCommandBySelector:selector]; } -- (void)_setFilesToOpen:(NSArray *)filesToOpen { - _filesToOpen = filesToOpen; -} - -(void)_addWindow:(NSWindow *)window { [_windows addObject:window]; } @@ -1337,11 +1324,27 @@ standardAboutPanel] retain]; @end int NSApplicationMain(int argc, const char *argv[]) { + __NSInitializeProcess(argc, argv); + NSAutoreleasePool *pool=[NSAutoreleasePool new]; NSBundle *bundle=[NSBundle mainBundle]; Class class=[bundle principalClass]; NSString *nibFile=[[bundle infoDictionary] objectForKey:@"NSMainNibFile"]; + if (argc > 1) { + NSMutableArray *arguments = [NSMutableArray arrayWithCapacity:argc-1]; + for (int i = 1; i < argc; i++) + if (argv[i][0] != '-') + [arguments addObject:[NSString stringWithUTF8String:argv[i]]]; + else if (argv[i][1] == '-' && argv[i][2] != '\0') + i++; + else // (argv[i] == "--") + break; + + if ([arguments count]) + [[NSUserDefaults standardUserDefaults] setObject:([arguments count] == 1) ? [arguments lastObject] : arguments forKey:@"NSOpen"]; + } + [NSClassFromString(@"Win32RunningCopyPipe") performSelector:@selector(startRunningCopyPipe)]; if(class==Nil) { @@ -1358,14 +1361,6 @@ int NSApplicationMain(int argc, const char *argv[]) { [pool release]; - if (argc > 1) - { - NSMutableArray *filesToOpen = [[NSMutableArray alloc] initWithCapacity:argc-1]; - for (int i = 1; i < argc; i++) - [filesToOpen addObject:[NSString stringWithUTF8String:argv[i]]]; - [NSApp _setFilesToOpen:filesToOpen]; - } - [NSApp run]; return 0; -- 2.11.4.GIT