xamarin / Xamarin.PropertyEditing

MIT License
24 stars 16 forks source link

Fix NRE when SelectionChanged is firing on a null object. #717

Closed CartBlanche closed 4 years ago

CartBlanche commented 4 years ago

Fixes https://github.com/xamarin/Xamarin.PropertyEditing/issues/718

netonjm commented 4 years ago

The fix seems to be ok for me, but just to ensure it's the right fix and there are no other regressions and break the IDE we could LOG in case of this.comboBox.SelectedValue is be null which is a not expected situation.

CartBlanche commented 4 years ago

@netonjm SelectedValue can be null? When you 1st create the control and populate it. you have a list but SelectedIndex will be -1 and therefore value will also be null?

From the Apple docs: If no item is selected, the value in this property is nil. Nothing is selected in a newly initialized combo box.

CartBlanche commented 4 years ago

But it is possible SelectedValue will be null if the control is reused, which seems to be the scenario we are hitting. Check put in for that.