Re: [Pyobjc-dev] Confusing crash that's fixed by adding NSBeep()
Brought to you by:
ronaldoussoren
From: Scott H. <sco...@gm...> - 2010-05-20 19:52:47
|
Thanks. Changing the method name to something other than action fixes the issue. Is action a bad choice for a method in general? -Scott On May 15, 2010, at 11:24 AM, Ronald Oussoren wrote: > > On 14 May, 2010, at 8:40, Scott Harris wrote: > >> I've got this obj-c object in a simple demo program: >> >> >> @implementation junker >> -(id) init >> { >> [super init]; >> NSLog(@"initing"); >> [self action]; >> return self; >> } >> -(void) action >> { >> NSLog(@"junk"); >> //NSBeep(); >> } >> @end >> >> I call it from Python in my App delegate like this: >> >> from Foundation import * >> from AppKit import * >> >> class PyObjCTestAppDelegate(NSObject): >> def applicationDidFinishLaunching_(self, sender): >> NSLog("Application did finish launching.") >> self.a=junker.alloc().init() >> >> def awakeFromNib(self): >> NSLog("Awoke from NIB") >> >> @objc.IBAction >> def buttonPress_(self, sender): >> NSLog("Button pressed!") >> self.a.action() >> >> The funny thing is that the program crashes when I press the button that calls buttonPress iff NSBeep is commented out, but runs fine if the NSBeep is uncommented. Strange. >> >> Here's the console output: >> 2010-05-14 00:39:23.924 PyObjCTest[99096:a0f] Awoke from NIB >> 2010-05-14 00:39:24.006 PyObjCTest[99096:a0f] Drawing >> 2010-05-14 00:39:24.069 PyObjCTest[99096:a0f] Application did finish launching. >> 2010-05-14 00:39:24.070 PyObjCTest[99096:a0f] initing >> 2010-05-14 00:39:24.070 PyObjCTest[99096:a0f] junk >> 2010-05-14 00:39:29.781 PyObjCTest[99096:a0f] Button Pressed >> 2010-05-14 00:39:29.782 PyObjCTest[99096:a0f] junk >> Program received signal: “EXC_BAD_ACCESS”. >> sharedlibrary apply-load-rules all >> >> Any ideas? > > The code looks correct, but indeed crashes. I'm looking into this, at first glance it seems that PyObjC is confused about the return type for [junker -action], and that's probably caused by the metadata files. > > One quick way to work around this: rename 'action' to something else. > > Ronald > |