Merge pull request #505 from JavaSaBr/v3.1
fixed the NPE with controls, thanks to JavaSaBr
This commit is contained in:
commit
7eb9463496
@ -55,6 +55,7 @@ import com.jme3.util.SafeArrayList;
|
||||
import com.jme3.util.TempVars;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
@ -1637,6 +1638,16 @@ public abstract class Spatial implements Savable, Cloneable, Collidable, Cloneab
|
||||
//controls = ic.readSavableArrayList("controlsList", null));
|
||||
controls.addAll(0, ic.readSavableArrayList("controlsList", null));
|
||||
|
||||
// remove all controls which wasn't loaded.
|
||||
if(controls.contains(null)) {
|
||||
logger.log(Level.WARNING, "This spatial has problems with loading controls.", this);
|
||||
|
||||
for (Iterator<Control> iterator = controls.iterator(); iterator.hasNext(); ) {
|
||||
final Control control = iterator.next();
|
||||
if(control == null) iterator.remove();
|
||||
}
|
||||
}
|
||||
|
||||
userData = (HashMap<String, Savable>) ic.readStringSavableMap("user_data", null);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user