From 72cc288cdfb7d9ab9933ead656b0da0be2759dd5 Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Wed, 2 Sep 2009 00:03:50 +0200 Subject: [PATCH] Don't use +[NSConnection defaultConnection] The defaultConnection message was deprecated in 10.6. --- src/MacVim/MMBackend.h | 1 + src/MacVim/MMBackend.m | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/MacVim/MMBackend.h b/src/MacVim/MMBackend.h index 292154b6..83f53133 100644 --- a/src/MacVim/MMBackend.h +++ b/src/MacVim/MMBackend.h @@ -21,6 +21,7 @@ NSMutableArray *inputQueue; NSMutableData *drawData; NSConnection *connection; + NSConnection *vimServerConnection; id appProxy; unsigned identifier; NSDictionary *colorDict; diff --git a/src/MacVim/MMBackend.m b/src/MacVim/MMBackend.m index b2e41fd3..3c2c3440 100644 --- a/src/MacVim/MMBackend.m +++ b/src/MacVim/MMBackend.m @@ -266,6 +266,7 @@ extern GuiFont gui_mch_retain_font(GuiFont font); [actionDict release]; actionDict = nil; [sysColorDict release]; sysColorDict = nil; [colorDict release]; colorDict = nil; + [vimServerConnection release]; vimServerConnection = nil; [super dealloc]; } @@ -679,8 +680,10 @@ extern GuiFont gui_mch_retain_font(GuiFont font); #ifdef MAC_CLIENTSERVER // The default connection is used for the client/server code. - [[NSConnection defaultConnection] setRootObject:nil]; - [[NSConnection defaultConnection] invalidate]; + if (vimServerConnection) { + [vimServerConnection setRootObject:nil]; + [vimServerConnection invalidate]; + } #endif } @@ -1321,22 +1324,28 @@ extern GuiFont gui_mch_retain_font(GuiFont font); - (void)registerServerWithName:(NSString *)name { NSString *svrName = name; - NSConnection *svrConn = [NSConnection defaultConnection]; unsigned i; + if (vimServerConnection) // Paranoia check, should always be nil + [vimServerConnection release]; + + vimServerConnection = [[NSConnection alloc] + initWithReceivePort:[NSPort port] + sendPort:nil]; + for (i = 0; i < MMServerMax; ++i) { NSString *connName = [self connectionNameFromServerName:svrName]; - if ([svrConn registerName:connName]) { + if ([vimServerConnection registerName:connName]) { ASLogInfo(@"Registered server with name: %@", svrName); // TODO: Set request/reply time-outs to something else? // // Don't wait for requests (time-out means that the message is // dropped). - [svrConn setRequestTimeout:0]; - //[svrConn setReplyTimeout:MMReplyTimeout]; - [svrConn setRootObject:self]; + [vimServerConnection setRequestTimeout:0]; + //[vimServerConnection setReplyTimeout:MMReplyTimeout]; + [vimServerConnection setRootObject:self]; // NOTE: 'serverName' is a global variable serverName = [svrName vimStringSave]; @@ -1346,8 +1355,8 @@ extern GuiFont gui_mch_retain_font(GuiFont font); #ifdef FEAT_TITLE need_maketitle = TRUE; #endif - [self queueMessage:SetServerNameMsgID data: - [svrName dataUsingEncoding:NSUTF8StringEncoding]]; + [self queueMessage:SetServerNameMsgID + data:[svrName dataUsingEncoding:NSUTF8StringEncoding]]; break; } -- 2.11.4.GIT