Skip to content

Commit 49823a0

Browse files
committed
ECS: make library lookup thread safe
1 parent 4ac5c02 commit 49823a0

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

app/src/processing/app/Mode.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ public File getReferenceFolder() {
282282
public void rebuildLibraryList() {
283283
//new Exception("Rebuilding library list").printStackTrace(System.out);
284284
// reset the table mapping imports to libraries
285-
importToLibraryTable = new HashMap<String, List<Library>>();
285+
HashMap<String, List<Library>> importToLibraryTable = new HashMap<>();
286286

287287
Library core = getCoreLibrary();
288288
if (core != null) {
@@ -323,6 +323,11 @@ public void rebuildLibraryList() {
323323
for (Library lib : contribLibraries) {
324324
lib.addPackageList(importToLibraryTable);
325325
}
326+
327+
// Make this Map thread-safe
328+
this.importToLibraryTable = Collections.unmodifiableMap(importToLibraryTable);
329+
330+
base.getEditors().forEach(Editor::librariesChanged);
326331
}
327332

328333

java/src/processing/mode/java/pdex/ErrorCheckerService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ private List<String> buildSketchLibraryClassPath(JavaMode mode,
703703
.filter(pckg -> !ignorableImport(pckg))
704704
.map(pckg -> {
705705
try {
706-
return mode.getLibrary(pckg); // TODO: this may not be thread-safe
706+
return mode.getLibrary(pckg);
707707
} catch (SketchException e) {
708708
return null;
709709
}

0 commit comments

Comments
 (0)