Allow setAppearance to accept a null Appearance parameter without

throwing NPE.
This commit is contained in:
kruland2607 2013-04-22 09:23:45 -05:00
parent f899b9fb2e
commit 173108c1a8

View File

@ -426,17 +426,20 @@ public abstract class RocketComponent implements ChangeSource, Cloneable, Iterab
*/ */
public void setAppearance(Appearance appearance) { public void setAppearance(Appearance appearance) {
this.appearance = appearance; this.appearance = appearance;
Decal d = this.appearance.getTexture(); if (this.appearance != null) {
if (d != null) { Decal d = this.appearance.getTexture();
d.getImage().addChangeListener(new StateChangeListener() { if (d != null) {
d.getImage().addChangeListener(new StateChangeListener() {
@Override @Override
public void stateChanged(EventObject e) { public void stateChanged(EventObject e) {
fireComponentChangeEvent(ComponentChangeEvent.TEXTURE_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.TEXTURE_CHANGE);
} }
}); });
}
} }
// CHECK - should this be a TEXTURE_CHANGE and not NONFUNCTIONAL_CHANGE?
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE); fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
} }