From aac15c0a8e5d7bd1be1bd32e96a8b2d96642d886 Mon Sep 17 00:00:00 2001 From: Manindra Moharana Date: Sun, 25 Aug 2013 18:38:09 +0530 Subject: [PATCH] thread sync bug fix, again. '-_- --- .../mode/experimental/ErrorBar.java | 47 ++++++++++--------- .../experimental/ErrorCheckerService.java | 26 +++++----- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/pdex/src/processing/mode/experimental/ErrorBar.java b/pdex/src/processing/mode/experimental/ErrorBar.java index 34c75904a..9ab47395b 100755 --- a/pdex/src/processing/mode/experimental/ErrorBar.java +++ b/pdex/src/processing/mode/experimental/ErrorBar.java @@ -164,29 +164,30 @@ public class ErrorBar extends JPanel { e.printStackTrace(); } // System.out.println("Total lines: " + totalLines); - - errorPointsOld.clear(); - for (ErrorMarker marker : errorPoints) { - errorPointsOld.add(marker); - } - errorPoints.clear(); - - // Each problem.getSourceLine() will have an extra line added - // because of - // class declaration in the beginning as well as default imports - synchronized (problems) { - for (Problem problem : problems) { - if (problem.getTabIndex() == currentTab) { - // Ratio of error line to total lines - float y = (problem.getLineNumber() - errorCheckerService.defaultImportsOffset) - / ((float) totalLines); - // Ratio multiplied by height of the error bar - y *= fheight - 15; // -15 is just a vertical offset - errorPoints - .add(new ErrorMarker(problem, (int) y, - problem.isError() ? ErrorMarker.Error - : ErrorMarker.Warning)); - // System.out.println("Y: " + y); + synchronized (errorPoints) { + errorPointsOld.clear(); + for (ErrorMarker marker : errorPoints) { + errorPointsOld.add(marker); + } + errorPoints.clear(); + + // Each problem.getSourceLine() will have an extra line added + // because of + // class declaration in the beginning as well as default imports + synchronized (problems) { + for (Problem problem : problems) { + if (problem.getTabIndex() == currentTab) { + // Ratio of error line to total lines + float y = (problem.getLineNumber() - errorCheckerService.defaultImportsOffset) + / ((float) totalLines); + // Ratio multiplied by height of the error bar + y *= fheight - 15; // -15 is just a vertical offset + errorPoints + .add(new ErrorMarker(problem, (int) y, + problem.isError() ? ErrorMarker.Error + : ErrorMarker.Warning)); + // System.out.println("Y: " + y); + } } } } diff --git a/pdex/src/processing/mode/experimental/ErrorCheckerService.java b/pdex/src/processing/mode/experimental/ErrorCheckerService.java index cec61813b..94baf0ede 100644 --- a/pdex/src/processing/mode/experimental/ErrorCheckerService.java +++ b/pdex/src/processing/mode/experimental/ErrorCheckerService.java @@ -831,19 +831,21 @@ public class ErrorCheckerService implements Runnable{ public void updateEditorStatus() { // editor.statusNotice("Position: " + // editor.getTextArea().getCaretLine()); - for (ErrorMarker emarker : editor.errorBar.errorPoints) { - if (emarker.getProblem().getLineNumber() == editor.getTextArea() - .getCaretLine() + 1) { - if (emarker.getType() == ErrorMarker.Warning) { - editor.statusNotice(emarker.getProblem().getMessage()); - //+ " : " + errorMsgSimplifier.getIDName(emarker.problem.getIProblem().getID())); - //TODO: this is temporary + synchronized (editor.errorBar.errorPoints) { + for (ErrorMarker emarker : editor.errorBar.errorPoints) { + if (emarker.getProblem().getLineNumber() == editor.getTextArea() + .getCaretLine() + 1) { + if (emarker.getType() == ErrorMarker.Warning) { + editor.statusNotice(emarker.getProblem().getMessage()); + //+ " : " + errorMsgSimplifier.getIDName(emarker.problem.getIProblem().getID())); + //TODO: this is temporary + } + else { + editor.statusError(emarker.getProblem().getMessage()); + //+ " : " + errorMsgSimplifier.getIDName(emarker.problem.getIProblem().getID())); + } + return; } - else { - editor.statusError(emarker.getProblem().getMessage()); - //+ " : " + errorMsgSimplifier.getIDName(emarker.problem.getIProblem().getID())); - } - return; } } if (editor.ta.getCaretLine() != lastCaretLine) {