PluggableListMorphByItem >> getCurrentSelectionIndex access directly a non-initailized instance variable

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

PluggableListMorphByItem >> getCurrentSelectionIndex access directly a non-initailized instance variable

cdelaunay
In pharo 1.2, MorphicToolBuilderTests >> testGetListSelection raise an error. This error is caused by PluggableListMorphByItem >> getCurrentSelectionIndex, which looks like that:

   getCurrentSelectionIndex
	"Answer the index of the current selection."
	| item |
	getIndexSelector == nil ifTrue: [^ 0].
	item := model perform: getIndexSelector.
	^ list findFirst: [ :x | x = item].

list is nil when runing the test. I guess that a better way is to use the accessor 'getList'. This method seems to make the correct initializations befor retrning the instance variable 'list'.
When replacing by:

   getCurrentSelectionIndex
	"Answer the index of the current selection."
	| item |
	getIndexSelector == nil ifTrue: [^ 0].
	item := model perform: getIndexSelector.
	^ self getList findFirst: [ :x | x = item].

The test pass.
I opened an issue: http://code.google.com/p/pharo/issues/detail?id=3028

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project