Re: [Pyobjc-dev] Confusing crash that's fixed by adding NSBeep()
Brought to you by:
ronaldoussoren
From: Jonathan <jon...@jo...> - 2010-05-20 20:22:25
|
It's probably python getting what you're doing confused with methods common to the target-action system. I've found it to be a good idea to avoid method names that come up in AppKiDo when using bridged languages with cocoa. Cheers jonathan Saggau Happily elbows-deep in python again, if only for a couple of weeks. :) On Thu, May 20, 2010 at 3:52 PM, Scott Harris <sco...@gm...> wrote: > 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 > > > ------------------------------------------------------------------------------ > > > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > > -- Jonathan Saggau jonathansaggau.com This amusement engaged me so much that [friends] were obliged to force me from it; and thus it is with every inclination I give into, it continues to augment, till at length it becomes so powerful, that I lose sight of everything except the favorite amusement. - Rousseau |