Re: [Pyobjc-dev] signal 11 when trying to access an NSComboBox's data source
Brought to you by:
ronaldoussoren
From: Ronald O. <ous...@ci...> - 2003-08-09 10:15:52
|
On Friday, 8 August, 2003, at 23:35, Steven D. Arnold wrote: > Hi, > > I am writing a program which has a controller object with an > awakeFromNib > function that begins like this: > > def awakeFromNib( self ): > self.word_type.setDataSource_( WordTypeManager.alloc().init( > self.db > ) ) > print "will this fail?" > print "value = %s" % self.word_type.dataSource() > print "no, it worked" > > The program dies on a signal 11 on the line where it attempts to print > the > data source. We never see the "value =" text or the "no, it worked" > string. Does it work any better when you assign the WorkTypeManager instance to an instance variable? As Martina already noted, the combobox probably doesn't retain it's datasource. There's not much we can do about that. Cocoa seems to do this quite often, probably to avoid reference counting cycles. Let's hope that Apple adds a real garbage collector in the future. The documentations mentions this, but obviously not clearly enough. I'll try to improve the documentation. BTW. Wouldn't it be possible to set the datasource within Interface builder, and use 'self.word_type.dataSource().setDB(self.db)' to finish initialising the datasource? That way you don't have to worry about reference counts at all. > > WordTypeManager is a class that is declared like this: > > class WordTypeManager( Foundation.NSObject, > AppKit.NSComboBoxDataSource, > ListManager ): BTW. You don't have to subclass from informal protocols anymore in 1.0b1. > > def init( self, db ): > > def numberOfItemsInComboBox_( self, comboBox ): > > def comboBox_objectValueForItemAtIndex_( self, comboBox, index ): > > def comboBox_indexOfItemWithStringValue_( self, comboBox, > str_value ): > > I can provide more detail about the code if needed. > > I have verified that self.word_type is an NSComboBox and that the > class's > outlet is connected to the right object in Interface Builder. > > I am using Python 2.3 (final) and PyObjC 1.0b1 (not CVS). Note that I > recently upgraded both Python and PyObjC, and the program worked fine > before > this upgrade, although I last used the program a couple months ago. I > am on > Mac OS X 10.2.6, on a dual-processor 1 GHz machine. > > Any ideas what might be causing this problem? > > -- > Steven D. Arnold st...@ne... > "One has a moral responsibility to disobey unjust laws." > Martin Luther King > News and Opinion Covering Free-Speech Issues in Media & Technology: > http://prime.neosynapse.net:8080/index.php > > > > > ------------------------------------------------------- > This SF.Net email sponsored by: Free pre-built ASP.NET sites including > Data Reports, E-commerce, Portals, and Forums are available now. > Download today and enter to win an XBOX or Visual Studio .NET. > http://aspnet.click-url.com/go/psa00100003ave/direct; > at.aspnet_072303_01/01 > _______________________________________________ > Pyobjc-dev mailing list > Pyo...@li... > https://lists.sourceforge.net/lists/listinfo/pyobjc-dev > |