mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
ECS: make library lookup thread safe
This commit is contained in:
@@ -282,7 +282,7 @@ public abstract class Mode {
|
||||
public void rebuildLibraryList() {
|
||||
//new Exception("Rebuilding library list").printStackTrace(System.out);
|
||||
// reset the table mapping imports to libraries
|
||||
importToLibraryTable = new HashMap<String, List<Library>>();
|
||||
HashMap<String, List<Library>> importToLibraryTable = new HashMap<>();
|
||||
|
||||
Library core = getCoreLibrary();
|
||||
if (core != null) {
|
||||
@@ -323,6 +323,11 @@ public abstract class Mode {
|
||||
for (Library lib : contribLibraries) {
|
||||
lib.addPackageList(importToLibraryTable);
|
||||
}
|
||||
|
||||
// Make this Map thread-safe
|
||||
this.importToLibraryTable = Collections.unmodifiableMap(importToLibraryTable);
|
||||
|
||||
base.getEditors().forEach(Editor::librariesChanged);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -703,7 +703,7 @@ public class ErrorCheckerService {
|
||||
.filter(pckg -> !ignorableImport(pckg))
|
||||
.map(pckg -> {
|
||||
try {
|
||||
return mode.getLibrary(pckg); // TODO: this may not be thread-safe
|
||||
return mode.getLibrary(pckg);
|
||||
} catch (SketchException e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user