On 8 Aug 2007, at 18:24, Yen-Ju Chen wrote:

>   It is originally written for Cocoa and AppKit always exists,
>   so it use NSApplication instead of NSRunLoop.
>   If you like, you can provide a patch to use NSRunLoop instead.

It doesn't seem to need NSRunLoop.  It needed an instance of  
NSAppliction for quite an interesting reason:

When it loaded up the bundles, it sent a +conformsToProtocol: message  
to each class to see if it was a unit testing class.

When this was done, the runtime sent a +initialize message to the class.

This then triggered a load of things, including an assertion failure  
in GSFontInfo, which caused the program to crash.

I have fixed this for the general case by adding a conformsToProtocol 
() function which checks for protocol conformance without sending any  
messages to the class[1], preventing it from being +initialize'd  
prematurely.  This also removes the need for the special case I added  
for NSProxy subclasses, which was caused by the fact that NSProxy  
tries to forward these messages to its delegate and falls over in a  
heap.  Since the messages are no longer sent, the problem goes away.

You can still break things if you implement +load, but the docs say  
you will probably break things if you use +load anyway, so it's not  
like you weren't warned :-)

This might be useful in other cases where you need to enumerate the  
classes conforming to a protocol but don't want any side-effects.   
It's in UKRunner.m, if anyone wants to steal it[2].

David

[1] Of course, since a Protocol is an object, the Protocol class will  
receive an +initialize message.
[2] The framework as a whole is under the ASL2, which isn't my  
favourite license.  The modifications I have made can be taken under  
the terms of the MITL if they are useful.

_______________________________________________
Etoile-dev mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-dev

Reply via email to