Browse Source

* Fix NPE in SkyFactory when used on android

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8312 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
sha..rd 14 years ago
parent
commit
c81a1a4d3e
1 changed files with 5 additions and 2 deletions
  1. 5 2
      engine/src/core/com/jme3/util/SkyFactory.java

+ 5 - 2
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.Image.Format;
 import com.jme3.texture.Texture;
 import com.jme3.texture.Texture;
 import com.jme3.texture.TextureCubeMap;
 import com.jme3.texture.TextureCubeMap;
+import java.nio.ByteBuffer;
 import java.util.ArrayList;
 import java.util.ArrayList;
 
 
 /**
 /**
@@ -113,7 +114,8 @@ public class SkyFactory {
 
 
         Format fmt = images[0].getFormat();
         Format fmt = images[0].getFormat();
         int width = images[0].getWidth();
         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]);
         checkImage(images[0]);
 
 
@@ -126,7 +128,8 @@ public class SkyFactory {
             if (image.getWidth() != width) {
             if (image.getWidth() != width) {
                 throw new IllegalArgumentException("Images must have same resolution");
                 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");
                 throw new IllegalArgumentException("Images must have same size");
             }
             }
         }
         }