[fix] Adds duplicate guard when add a 'ComponentChangeListener' to the rocket

This commit is contained in:
Daniel_M_Williams 2020-04-05 10:30:08 -04:00
parent 58eb9fff90
commit 644404b070
2 changed files with 3 additions and 5 deletions

View File

@ -413,7 +413,9 @@ public class Rocket extends ComponentAssembly {
@Override
public void addComponentChangeListener(ComponentChangeListener l) {
checkState();
listenerList.add(l);
if( ! listenerList.contains(l)) {
listenerList.add(l);
}
log.trace("Added ComponentChangeListener " + l + ", current number of listeners is " +
listenerList.size());
}

View File

@ -60,10 +60,6 @@ public class ComponentConfigDialog extends JDialog implements ComponentChangeLis
* @param component Component to configure.
*/
private void setComponent(OpenRocketDocument document, RocketComponent component) {
if (this.document != null) {
this.document.getRocket().removeComponentChangeListener(this);
}
if (configurator != null) {
// Remove listeners by setting all applicable models to null
GUIUtil.setNullModels(configurator); // null-safe