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) {
this.appearance = appearance;
Decal d = this.appearance.getTexture();
if (d != null) {
d.getImage().addChangeListener(new StateChangeListener() {
if (this.appearance != null) {
Decal d = this.appearance.getTexture();
if (d != null) {
d.getImage().addChangeListener(new StateChangeListener() {
@Override
public void stateChanged(EventObject e) {
fireComponentChangeEvent(ComponentChangeEvent.TEXTURE_CHANGE);
}
@Override
public void stateChanged(EventObject e) {
fireComponentChangeEvent(ComponentChangeEvent.TEXTURE_CHANGE);
}
});
});
}
}
// CHECK - should this be a TEXTURE_CHANGE and not NONFUNCTIONAL_CHANGE?
fireComponentChangeEvent(ComponentChangeEvent.NONFUNCTIONAL_CHANGE);
}