Reimplement ComponentPreset to be a bag of typed parameters. This provides greater...
[debian/openrocket] / core / src / net / sf / openrocket / gui / adaptors / BodyTubePresetModel.java
index 1f46062ac1a85f9fda5f75426affe232fcdcd7bd..08850b8f0a53a7947bef2e218f8b5bab42b8eb7d 100644 (file)
@@ -43,6 +43,8 @@ public class BodyTubePresetModel extends AbstractListModel implements ComboBoxMo
                }
                @Override
                public boolean equals(Object obj) {
+                       // I don't know why the default equals generated by Eclipse does not work.
+                       // instead of relying on bt.equals(other.bt), we have to compare the hashcodes of those objects.
                        if (this == obj)
                                return true;
                        if (obj == null)
@@ -53,9 +55,9 @@ public class BodyTubePresetModel extends AbstractListModel implements ComboBoxMo
                        if (bt == null) {
                                if (other.bt != null)
                                        return false;
-                       } else if (!bt.equals(other.bt))
+                       } else if (other.bt == null)
                                return false;
-                       return true;
+                       return bt.hashCode() == other.bt.hashCode();
                }
        }