From c81a1a4d3eec7a10b63adbaf0c9ecf6cdaf3c0e6 Mon Sep 17 00:00:00 2001 From: "sha..rd" Date: Tue, 27 Sep 2011 02:05:03 +0000 Subject: [PATCH] * Fix NPE in SkyFactory when used on android git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8312 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- engine/src/core/com/jme3/util/SkyFactory.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/engine/src/core/com/jme3/util/SkyFactory.java b/engine/src/core/com/jme3/util/SkyFactory.java index 71863e9bd..7a48803b5 100644 --- a/engine/src/core/com/jme3/util/SkyFactory.java +++ b/engine/src/core/com/jme3/util/SkyFactory.java @@ -13,6 +13,7 @@ import com.jme3.texture.Image; import com.jme3.texture.Image.Format; import com.jme3.texture.Texture; import com.jme3.texture.TextureCubeMap; +import java.nio.ByteBuffer; import java.util.ArrayList; /** @@ -113,7 +114,8 @@ public class SkyFactory { Format fmt = images[0].getFormat(); int width = images[0].getWidth(); - int size = images[0].getData(0).capacity(); + ByteBuffer data = images[0].getData(0); + int size = data != null ? data.capacity() : 0; checkImage(images[0]); @@ -126,7 +128,8 @@ public class SkyFactory { if (image.getWidth() != width) { throw new IllegalArgumentException("Images must have same resolution"); } - if (image.getData(0).capacity() != size) { + ByteBuffer data2 = image.getData(0); + if (data2.capacity() != size) { throw new IllegalArgumentException("Images must have same size"); } }