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.
This commit is contained in:
Bjorn Winckler
2011-05-31 11:39:01 +02:00
parent c60f09b824
commit d8066f8a5d
+15 -7
View File
@@ -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