From 94f542912b639ffb3b72bf8ebbd92410f764cb3d Mon Sep 17 00:00:00 2001 From: javasabr Date: Sun, 3 Sep 2017 16:22:46 +0300 Subject: [PATCH] Fixed NPE and ConcurrentModificationException during cloning TechniqueDef. --- .../main/java/com/jme3/material/ShaderGenerationInfo.java | 8 +++++++- .../src/main/java/com/jme3/material/TechniqueDef.java | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/jme3-core/src/main/java/com/jme3/material/ShaderGenerationInfo.java b/jme3-core/src/main/java/com/jme3/material/ShaderGenerationInfo.java index ab06cdf0b..8efc56679 100644 --- a/jme3-core/src/main/java/com/jme3/material/ShaderGenerationInfo.java +++ b/jme3-core/src/main/java/com/jme3/material/ShaderGenerationInfo.java @@ -190,7 +190,13 @@ public class ShaderGenerationInfo implements Savable, Cloneable { @Override protected ShaderGenerationInfo clone() throws CloneNotSupportedException { - ShaderGenerationInfo clone = (ShaderGenerationInfo) super.clone(); + final ShaderGenerationInfo clone = (ShaderGenerationInfo) super.clone(); + clone.attributes = new ArrayList<>(); + clone.vertexUniforms = new ArrayList<>(); + clone.fragmentUniforms = new ArrayList<>(); + clone.fragmentGlobals = new ArrayList<>(); + clone.unusedNodes = new ArrayList<>(); + for (ShaderNodeVariable attribute : attributes) { clone.attributes.add(attribute.clone()); diff --git a/jme3-core/src/main/java/com/jme3/material/TechniqueDef.java b/jme3-core/src/main/java/com/jme3/material/TechniqueDef.java index 429522c59..882d2b63a 100644 --- a/jme3-core/src/main/java/com/jme3/material/TechniqueDef.java +++ b/jme3-core/src/main/java/com/jme3/material/TechniqueDef.java @@ -801,6 +801,7 @@ public class TechniqueDef implements Savable, Cloneable { clone.paramToDefineId.putAll(paramToDefineId); if (shaderNodes != null) { + clone.shaderNodes = new ArrayList<>(); for (ShaderNode shaderNode : shaderNodes) { clone.shaderNodes.add(shaderNode.clone()); }