[SVN] r2318 (using distributed objects in plugins)

Chris Thomas chris at cjack.com
Mon Nov 28 04:38:54 UTC 2005


FYI.

Invoking +[NSConnection defaultConnection] returns the default  
connection for the current thread, creating it if it doesn't exist.  
TextMate uses +defaultConnection (or something that calls it  
indirectly) to vend an object for 'mate' to communicate with. Later,  
when the tmplugin is initialized and wants to vend an object itself,  
it too might use [NSConnection defaultConnection], which then returns  
the previously-created NSConnection. But one connection can only vend  
one root object. So TM's root object is orphaned and there's no way  
for 'mate' to speak with TextMate.

The solution, if you're vending from TM's main runloop, is to replace  
the call to +defaultConnection with  
+connectionWithReceivePort:sendPort:, as in:

	NSPort *		newPort			= [NSPort port];
	NSConnection *	connection		= [NSConnection  
connectionWithReceivePort:newPort sendPort:newPort];

And be sure to [connection retain].

Chris




More information about the textmate-dev mailing list