Skip to content

Commit a1887df

Browse files
Avoid concurrency error while loading menus in backgroud thread.
No call onBoardOrPortChange, because this is called in Base Contructor
1 parent 824a8b3 commit a1887df

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

app/src/processing/app/Base.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public class Base {
129129
// actually used are determined by the preferences, which are shared)
130130
private List<JMenu> boardsCustomMenus;
131131
private List<JMenuItem> programmerMenus;
132+
private boolean boardsCustomMenusLoading;
132133

133134
private PdeKeywords pdeKeywords;
134135
private final List<JMenuItem> recentSketchesMenuItems = new LinkedList<>();
@@ -1284,13 +1285,6 @@ public void rebuildExamplesMenu(JMenuLazy menu) {
12841285
return;
12851286
}
12861287

1287-
new Throwable().printStackTrace();
1288-
1289-
boolean showDialog = PreferencesData.getBoolean("menu.examples.dialog", true);
1290-
if(showDialog) {
1291-
return;
1292-
}
1293-
12941288
// Avoid call twice from "Editor.buildMenuBar"
12951289
if(menu.isLoading()) return;
12961290

@@ -1564,6 +1558,7 @@ protected void onIndexesUpdated() throws Exception {
15641558

15651559
public void rebuildBoardsMenu() throws Exception {
15661560
boardsCustomMenus = new LinkedList<>();
1561+
boardsCustomMenusLoading = true;
15671562

15681563
// Execute in backgroud thread, no need UI thread because no rendering needed
15691564
menuExecutor.execute(() -> {
@@ -1689,6 +1684,8 @@ public void actionPerformed(ActionEvent actionevent) {
16891684
menuItemToClick.getAction().actionPerformed(new ActionEvent(this, -1, ""));
16901685
}
16911686

1687+
boardsCustomMenusLoading = false;
1688+
16921689
});
16931690

16941691
}
@@ -1717,7 +1714,10 @@ public void actionPerformed(ActionEvent actionevent) {
17171714
BaseNoGui.selectBoard((TargetBoard) getValue("b"));
17181715
filterVisibilityOfSubsequentBoardMenus(boardsCustomMenus, (TargetBoard) getValue("b"), 1);
17191716

1720-
onBoardOrPortChange();
1717+
// Avoid concurrency error while loading menus in backgroud thread.
1718+
// No call onBoardOrPortChange, because this is called in Base Contructor
1719+
if(!boardsCustomMenusLoading) onBoardOrPortChange();
1720+
17211721
rebuildImportMenu(Editor.importMenu);
17221722
rebuildExamplesMenu(Editor.examplesMenu);
17231723
rebuildProgrammerMenu();

arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public void setArchitecturePriority(String arch) {
142142
priorityComparator = new UserLibraryPriorityComparator(arch);
143143
}
144144

145-
public void rescanLibraries() {
145+
public synchronized void rescanLibraries() {
146146
// Clear all installed flags
147147
installedLibraries.clear();
148148

0 commit comments

Comments
 (0)