From d8066f8a5d60ee15d1843a4479576f3403ceda5b Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Tue, 31 May 2011 11:39:01 +0200 Subject: [PATCH] Fix untitled window open regression Fixes bug where Quickstart would cause no window to open when the Dock icon was clicked with MacVim already launched and no open windows. This commit also plugs a minor memory leak. --- src/MacVim/MMAppController.m | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index 2b4c09abdb..8fdc4e429a 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -416,11 +416,19 @@ fsEventCallback(ConstFSEventStreamRef streamRef, if (desc && ![desc booleanValue]) return NO; - // Never open an untitled window if there is at least one open window or if - // there are processes that are currently launching. - if ([vimControllers count] > 0 || [pidArguments count] > 0) + // Never open an untitled window if there is at least one open window. + if ([vimControllers count] > 0) return NO; + // Don't open an untitled window if there are processes about to launch... + NSUInteger numLaunching = [pidArguments count]; + if (numLaunching > 0) { + // ...unless the launching process is being preloaded + NSNumber *key = [NSNumber numberWithInt:preloadPid]; + if (numLaunching != 1 || [pidArguments objectForKey:key] == nil) + return NO; + } + // NOTE! This way it possible to start the app with the command-line // argument '-nowindow yes' and no window will be opened by default but // this argument will only be heeded when the application is opening. @@ -2249,6 +2257,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef, int pid = [vc pid]; NSNumber *pidKey = [NSNumber numberWithInt:pid]; + id args = [pidArguments objectForKey:pidKey]; if (preloadPid == pid) { // This controller was preloaded, so add it to the cache and @@ -2260,7 +2269,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef, } else { [vimControllers addObject:vc]; - id args = [pidArguments objectForKey:pidKey]; if (args && [NSNull null] != args) [vc passArguments:args]; @@ -2270,10 +2278,10 @@ fsEventCallback(ConstFSEventStreamRef streamRef, // which is how we detect if the process was launched from the // terminal. if (!args) [self activateWhenNextWindowOpens]; - - if (args) - [pidArguments removeObjectForKey:pidKey]; } + + if (args) + [pidArguments removeObjectForKey:pidKey]; } - (NSDictionary *)convertVimControllerArguments:(NSDictionary *)args