From dc809e10753d783db542a2a53e1156118e0bdf51 Mon Sep 17 00:00:00 2001 From: "jussi.koskela" Date: Wed, 26 Nov 2014 15:34:09 +0000 Subject: [PATCH] (fixes #5507) Equation validator throws ArrayIndexOutOfBoundsException when using a function as array index git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30612 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../org/simantics/sysdyn/ui/utils/ArrayVariableUtils.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ArrayVariableUtils.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ArrayVariableUtils.java index 73663c77..5bd63aaa 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ArrayVariableUtils.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/utils/ArrayVariableUtils.java @@ -72,7 +72,10 @@ public class ArrayVariableUtils { for(int i = 0; i < elements.length && i < enumerations.size(); i++) { String trimmedElement = elements[i].trim(); - if (trimmedElement.charAt(0) == '{' && trimmedElement.charAt(trimmedElement.length() - 1) == '}') { + if (trimmedElement.length() == 0) { + // Empty element is returned if the index is a function + continue; + } else if (trimmedElement.charAt(0) == '{' && trimmedElement.charAt(trimmedElement.length() - 1) == '}') { // Something like "{a, b, c}" String[] rangeComponents = trimmedElement.substring(1, trimmedElement.length() - 1).split(","); // Single range component, equals to the enumeration at that index -- 2.47.1