Fix for NPE the first time you create a new image and try to draw -- the state management was setting a null when there was no previous state

This commit is contained in:
Brendan Robert 2015-10-14 01:28:54 -05:00
parent 6e2187087f
commit 7ac3f974b9

View File

@ -100,7 +100,12 @@ public class AppleImageEditor extends ImageEditor implements EventHandler<MouseE
public void setState(EnumMap oldState) {
state.putAll(oldState);
changeCurrentPattern((FillPattern) state.get(StateVars.PATTERN));
_setDrawMode((DrawMode) state.get(StateVars.DRAW_MODE));
DrawMode oldDrawMode = (DrawMode) state.get(StateVars.DRAW_MODE);
if (oldDrawMode != null) {
_setDrawMode(oldDrawMode);
} else {
state.put(StateVars.DRAW_MODE, currentDrawMode);
}
}
@Override