jsbml icon indicating copy to clipboard operation
jsbml copied to clipboard

No property change happens when a value is explicitly set to NaN that was undefined before

Open draeger opened this issue 1 year ago • 0 comments

When listening to changes in a model, the TreeNodeChangeListener is activated when a previously undefined double value is explicitly set to NaN but then nothing happens because we are comparing the old value with the new value using a call to the equals method here. Appearantly, undefined values are NaN behind the scenes. The setValue method still notices the difference and calls the change listeners because there the difference is identified using an != operator (see here).

My suggestion for a fix would be to change the check in AbstractTreeNode so that in addition to !equals also a check via != is performed, i.e.,

else if ((oldValue != null) && (!oldValue.equals(newValue) || oldValue != newValue))

Could such a change have any unwanted effects, too?

draeger avatar Nov 24 '22 22:11 draeger