Fixed an issue with how reading text files with bufferedReader was done. Using a null check for EOF instead of buffer.ready(). This was causing a NPE on android 4.4

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10923 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
experimental
rem..om 11 years ago
parent 45e82cdbb1
commit 9d63a7fc02
  1. 7
      engine/src/core-plugins/com/jme3/font/plugins/BitmapFontLoader.java
  2. 4
      engine/src/core-plugins/com/jme3/shader/plugins/GLSLLoader.java

@ -43,23 +43,22 @@ import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import org.omg.PortableInterceptor.SYSTEM_EXCEPTION;
public class BitmapFontLoader implements AssetLoader { public class BitmapFontLoader implements AssetLoader {
private BitmapFont load(AssetManager assetManager, String folder, InputStream in) throws IOException{ private BitmapFont load(AssetManager assetManager, String folder, InputStream in) throws IOException{
MaterialDef spriteMat = MaterialDef spriteMat =
(MaterialDef) assetManager.loadAsset(new AssetKey("Common/MatDefs/Misc/Unshaded.j3md")); (MaterialDef) assetManager.loadAsset(new AssetKey("Common/MatDefs/Misc/Unshaded.j3md"));
BitmapCharacterSet charSet = new BitmapCharacterSet(); BitmapCharacterSet charSet = new BitmapCharacterSet();
Material[] matPages = null; Material[] matPages = null;
BitmapFont font = new BitmapFont(); BitmapFont font = new BitmapFont();
BufferedReader reader = new BufferedReader(new InputStreamReader(in)); BufferedReader reader = new BufferedReader(new InputStreamReader(in));
String regex = "[\\s=]+"; String regex = "[\\s=]+";
font.setCharSet(charSet); font.setCharSet(charSet);
while (reader.ready()){ String line;
String line = reader.readLine(); while ((line = reader.readLine())!=null){
String[] tokens = line.split(regex); String[] tokens = line.split(regex);
if (tokens[0].equals("info")){ if (tokens[0].equals("info")){
// Get rendered size // Get rendered size

@ -82,8 +82,8 @@ public class GLSLLoader implements AssetLoader {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
BufferedReader bufReader = new BufferedReader(reader); BufferedReader bufReader = new BufferedReader(reader);
try { try {
while (bufReader.ready()) { String ln;
String ln = bufReader.readLine(); while ((ln = bufReader.readLine()) != null) {
if (ln.trim().startsWith("#import ")) { if (ln.trim().startsWith("#import ")) {
ln = ln.trim().substring(8).trim(); ln = ln.trim().substring(8).trim();
if (ln.startsWith("\"") && ln.endsWith("\"") && ln.length() > 3) { if (ln.startsWith("\"") && ln.endsWith("\"") && ln.length() > 3) {

Loading…
Cancel
Save