Skip to content

Commit b17184f

Browse files
authored
Merge pull request #1371 from ychin/no-exception-when-quitting
Don't throw Objective C exception when quitting MacVim
2 parents 1ec231d + 0c93e18 commit b17184f

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/MacVim/MMAppController.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,15 @@ - (void)applicationWillTerminate:(NSNotification *)notification
759759
andEventID:'MOD '];
760760
#endif
761761

762+
// We are hard shutting down the app here by terminating all Vim processes
763+
// and then just quit without cleanly removing each Vim controller. We
764+
// don't want the straggler controllers to still interact with the now
765+
// invalid connections, so we just mark them as uninitialized.
766+
for (NSUInteger i = 0, count = [vimControllers count]; i < count; ++i) {
767+
MMVimController *vc = [vimControllers objectAtIndex:i];
768+
[vc uninitialize];
769+
}
770+
762771
// This will invalidate all connections (since they were spawned from this
763772
// connection).
764773
[connection invalidate];

src/MacVim/MMVimController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
}
5858

5959
- (id)initWithBackend:(id)backend pid:(int)processIdentifier;
60+
- (void)uninitialize;
6061
- (unsigned)vimControllerId;
6162
- (id)backendProxy;
6263
- (int)pid;

src/MacVim/MMVimController.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,15 @@ - (void)dealloc
248248
[super dealloc];
249249
}
250250

251+
/// This should only be called by MMAppController when it's doing an app quit.
252+
/// We just wait for all Vim processes to terminate instad of individually
253+
/// closing each MMVimController. We simply unset isInitialized to prevent it
254+
/// from handling and sending messages to now invalid Vim connections.
255+
- (void)uninitialize
256+
{
257+
isInitialized = NO;
258+
}
259+
251260
- (unsigned)vimControllerId
252261
{
253262
return identifier;

0 commit comments

Comments
 (0)