diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index 904db5c161..5cf6cbb1f4 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -759,6 +759,15 @@ - (void)applicationWillTerminate:(NSNotification *)notification andEventID:'MOD ']; #endif + // We are hard shutting down the app here by terminating all Vim processes + // and then just quit without cleanly removing each Vim controller. We + // don't want the straggler controllers to still interact with the now + // invalid connections, so we just mark them as uninitialized. + for (NSUInteger i = 0, count = [vimControllers count]; i < count; ++i) { + MMVimController *vc = [vimControllers objectAtIndex:i]; + [vc uninitialize]; + } + // This will invalidate all connections (since they were spawned from this // connection). [connection invalidate]; diff --git a/src/MacVim/MMVimController.h b/src/MacVim/MMVimController.h index c1dda229a7..6ab169adc8 100644 --- a/src/MacVim/MMVimController.h +++ b/src/MacVim/MMVimController.h @@ -57,6 +57,7 @@ } - (id)initWithBackend:(id)backend pid:(int)processIdentifier; +- (void)uninitialize; - (unsigned)vimControllerId; - (id)backendProxy; - (int)pid; diff --git a/src/MacVim/MMVimController.m b/src/MacVim/MMVimController.m index c9e1063cbd..891ec617e7 100644 --- a/src/MacVim/MMVimController.m +++ b/src/MacVim/MMVimController.m @@ -248,6 +248,15 @@ - (void)dealloc [super dealloc]; } +/// This should only be called by MMAppController when it's doing an app quit. +/// We just wait for all Vim processes to terminate instad of individually +/// closing each MMVimController. We simply unset isInitialized to prevent it +/// from handling and sending messages to now invalid Vim connections. +- (void)uninitialize +{ + isInitialized = NO; +} + - (unsigned)vimControllerId { return identifier;