Skip to content

Commit f261a62

Browse files
plugins/mra-plots/rtplot/RealTimePlotGroovy: Fix to prevent erroneous script from endless error loop.
1 parent 0596778 commit f261a62

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

plugins-dev/mra-plots/src/java/pt/lsts/neptus/plugins/rtplot/RealTimePlotGroovy.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,22 @@ public void runScript(String script) {
457457
releaseThis();
458458
}
459459
catch (Exception e) {
460-
traceScript = previousScript;
460+
if (traceScript == null || traceScript.equals(previousScript)) {
461+
// This avoids endless error loop
462+
// comment every line of the script in the variable traceScript
463+
if (traceScript != null) {
464+
StringBuilder sb = new StringBuilder();
465+
for (String line : traceScript.split("\\r?\\n")) {
466+
sb.append("//").append(line).append("\n");
467+
}
468+
traceScript = sb.toString();
469+
} else {
470+
traceScript = "";
471+
}
472+
previousScript = traceScript;
473+
} else {
474+
traceScript = previousScript;
475+
}
461476
if (editSettings.isShowing())
462477
throw e;
463478
//GuiUtils.errorMessage(editSettings, "Error Parsing Script1", e.getLocalizedMessage());

0 commit comments

Comments
 (0)