Browse Source

Small fix for when a MatDef file is faulty: Prevent a NPE

MeFisto94 9 years ago
parent
commit
4582e4b0fe

+ 6 - 5
jme3-materialeditor/src/com/jme3/gde/materials/MaterialPreviewRenderer.java

@@ -163,12 +163,13 @@ public class MaterialPreviewRenderer implements SceneListener {
     }
 
     public Material reloadMaterial(Material mat) {
-
-        ((ProjectAssetManager) mat.getMaterialDef().getAssetManager()).clearCache();
-
-        //creating a dummy mat with the mat def of the mat to reload
-        Material dummy = new Material(mat.getMaterialDef());
+        Material dummy;
         try {
+            ((ProjectAssetManager) mat.getMaterialDef().getAssetManager()).clearCache();
+
+            //creating a dummy mat with the mat def of the mat to reload
+            dummy = new Material(mat.getMaterialDef());
+        
             for (MatParam matParam : mat.getParams()) {
                 dummy.setParam(matParam.getName(), matParam.getVarType(), matParam.getValue());
             }