Skip to content

Commit 95366b5

Browse files
authored
Merge pull request #1427 from ychin/fix-nsconnection-shutdown-issues
Fix Vim crashing when querying serverlist when quitting
2 parents 7b8a803 + f4e6078 commit 95366b5

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

src/MacVim/MMBackend.m

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ - (void)dealloc
273273
[outputQueue release]; outputQueue = nil;
274274
[drawData release]; drawData = nil;
275275
[connection release]; connection = nil;
276+
[appProxy release]; appProxy = nil;
276277
[actionDict release]; actionDict = nil;
277278
[sysColorDict release]; sysColorDict = nil;
278279
[colorDict release]; colorDict = nil;
@@ -1746,11 +1747,11 @@ - (NSArray *)serverList
17461747
{
17471748
NSArray *list = nil;
17481749

1749-
if ([self connection]) {
1750-
id proxy = [connection rootProxy];
1751-
[proxy setProtocolForProxy:@protocol(MMAppProtocol)];
1752-
1750+
if ([self connection] && [connection isValid]) {
17531751
@try {
1752+
id proxy = [connection rootProxy];
1753+
[proxy setProtocolForProxy:@protocol(MMAppProtocol)];
1754+
17541755
list = [proxy serverList];
17551756
}
17561757
@catch (NSException *ex) {
@@ -2535,6 +2536,14 @@ - (void)connectionDidDie:(NSNotification * UNUSED)notification
25352536

25362537
ASLogNotice(@"Main connection was lost before process had a chance "
25372538
"to terminate; preserving swap files.");
2539+
2540+
// Just release the connection, in case some autocmd's end up triggering
2541+
// IPC calls during shutdown. If other code use isValid checks this is a
2542+
// little unnecessary, but it just helps prevent issues with code that use
2543+
// the connection or proxy without checking for validity first.
2544+
[connection release]; connection = nil;
2545+
[appProxy release]; appProxy = nil;
2546+
25382547
getout_preserve_modified(1);
25392548
}
25402549

0 commit comments

Comments
 (0)