[Pythonmac-SIG] PyObjC: debugging error-less crashes?
ronaldoussoren at mac.com
Thu Jul 24 07:52:05 CEST 2008
On 23 Jul, 2008, at 23:26, Gary Bernhardt wrote:
> You need to wrap you alertEnded... method with
> def alertEnded(self, alert, choice, context):
> (Methods wrapped with endSheetMethod don't need the ObjC name
> mangling, so you can name it whatever you want.)
> I have a very weak understanding of why this is needed, but it's
> something related to sheet callback methods not having a fixed
That's the right fix, and it is needed because the arguments of the
callback (the alertEnded method above) aren't all instances of
NSObject. Some of them are basic C types. If you don't tell PyObjC
about this the bridge won't know that and will happely treat a C
integer or 'void*' value as an object reference, which will almost
certainly crash your program.
Decorators like endSheetMethod aren't needed for most other methods
because either the method signature is simple (all arguments are
objects, as is the return value), or PyObjC can deduct the correct
method signature from the super class or protocol definitions.
More information about the Pythonmac-SIG