From 162808f0cd0dd8aae05ba55f0aa611fa790cc4ae Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Thu, 23 Jan 2014 16:04:35 +0000 Subject: [PATCH] Bugfix: fixed an issue that could cause NPE to be thrown, when somehow object or skeleton animation maps were null. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@11000 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../blender/com/jme3/asset/BlenderKey.java | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/engine/src/blender/com/jme3/asset/BlenderKey.java b/engine/src/blender/com/jme3/asset/BlenderKey.java index 30bbd212b..a1f78f653 100644 --- a/engine/src/blender/com/jme3/asset/BlenderKey.java +++ b/engine/src/blender/com/jme3/asset/BlenderKey.java @@ -553,20 +553,28 @@ public class BlenderKey extends ModelKey { oc.write(skyGeneratedTextureShape, "sky-generated-texture-shape", SkyGeneratedTextureShape.SPHERE); oc.write(optimiseTextures, "optimise-textures", false); - oc.write(nodeAnimationMap.size(), "node-anims-map-size", 0); - int counter = 0; - for (Entry> entry : nodeAnimationMap.entrySet()) { - oc.write(entry.getKey(), "node-anim-" + counter, null); - oc.write(entry.getValue().toArray(new String[entry.getValue().size()]), "node-anims-" + counter, null); - ++counter; - } - - oc.write(skeletonAnimationMap.size(), "skeleton-anims-map-size", 0); - counter = 0; - for (Entry> entry : skeletonAnimationMap.entrySet()) { - oc.write(entry.getKey(), "skeleton-anim-" + counter, null); - oc.write(entry.getValue().toArray(new String[entry.getValue().size()]), "skeleton-anims-" + counter, null); - ++counter; + if (nodeAnimationMap == null) { + oc.write(0, "node-anims-map-size", 0); + } else { + oc.write(nodeAnimationMap.size(), "node-anims-map-size", 0); + int counter = 0; + for (Entry> entry : nodeAnimationMap.entrySet()) { + oc.write(entry.getKey(), "node-anim-" + counter, null); + oc.write(entry.getValue().toArray(new String[entry.getValue().size()]), "node-anims-" + counter, null); + ++counter; + } + } + + if (skeletonAnimationMap == null) { + oc.write(0, "skeleton-anims-map-size", 0); + } else { + oc.write(skeletonAnimationMap.size(), "skeleton-anims-map-size", 0); + int counter = 0; + for (Entry> entry : skeletonAnimationMap.entrySet()) { + oc.write(entry.getKey(), "skeleton-anim-" + counter, null); + oc.write(entry.getValue().toArray(new String[entry.getValue().size()]), "skeleton-anims-" + counter, null); + ++counter; + } } }