FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Move updateErrorPoints background work to UI thread · codetorex/processing@9a15a88 · GitHub

Repository navigation

Commit 9a15a88

Browse files
committed
Move updateErrorPoints background work to UI thread
1 parent d1e20da commit 9a15a88

1 file changed

Lines changed: 15 additions & 35 deletions

File tree

‎java/src/processing/mode/java/MarkerColumn.java‎

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import java.util.List;
3333

3434
import javax.swing.JPanel;
35-
import javax.swing.SwingWorker;
3635
import javax.swing.text.BadLocationException;
3736

3837
import processing.app.Mode;
@@ -115,40 +114,21 @@ public List<LineMarker> getErrorPoints() {
115114
}
116115

117116

118-
synchronized public void updateErrorPoints(final List<Problem> problems) {
119-
// NOTE: ErrorMarkers are calculated for the present tab only Error Marker
120-
// index in the arraylist is LOCALIZED for current tab. Also, update is in
121-
// the UI thread via SwingWorker to prevent concurrency issues. [Manindra]
122-
try {
123-
new SwingWorker() {
124-
protected Object doInBackground() throws Exception {
125-
Sketch sketch = editor.getSketch();
126-
int currentTab = sketch.getCurrentCodeIndex();
127-
errorPoints = new ArrayList<>();
128-
129-
// Each problem.getSourceLine() will have an extra line added because
130-
// of class declaration in the beginning as well as default imports
131-
synchronized (problems) {
132-
for (Problem problem : problems) {
133-
if (problem.getTabIndex() == currentTab) {
134-
errorPoints.add(new LineMarker(problem, problem.isError()));
135-
}
136-
}
137-
}
138-
139-
recalculateMarkerPositions();
140-
return null;
141-
}
142-
143-
protected void done() {
144-
repaint();
145-
editor.getErrorChecker().updateEditorStatus();
146-
}
147-
}.execute();
148-
149-
} catch (Exception ex) {
150-
ex.printStackTrace();
151-
}
117+
public void updateErrorPoints(final List<Problem> problems) {
118+
// NOTE: ErrorMarkers are calculated for the present tab only Error Marker
119+
// index in the arraylist is LOCALIZED for current tab.
120+
Sketch sketch = editor.getSketch();
121+
int currentTab = sketch.getCurrentCodeIndex();
122+
errorPoints = Collections.synchronizedList(new ArrayList<LineMarker>());
123+
// Each problem.getSourceLine() will have an extra line added because
124+
// of class declaration in the beginning as well as default imports
125+
for (Problem problem : problems) {
126+
if (problem.getTabIndex() == currentTab) {
127+
errorPoints.add(new LineMarker(problem, problem.isError()));
128+
}
129+
}
130+
repaint();
131+
editor.getErrorChecker().updateEditorStatus();
152132
}
153133

154134

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL