@@ -129,6 +129,7 @@ public class Base {
129
129
// actually used are determined by the preferences, which are shared)
130
130
private List <JMenu > boardsCustomMenus ;
131
131
private List <JMenuItem > programmerMenus ;
132
+ private boolean boardsCustomMenusLoading ;
132
133
133
134
private PdeKeywords pdeKeywords ;
134
135
private final List <JMenuItem > recentSketchesMenuItems = new LinkedList <>();
@@ -1284,13 +1285,6 @@ public void rebuildExamplesMenu(JMenuLazy menu) {
1284
1285
return ;
1285
1286
}
1286
1287
1287
- new Throwable ().printStackTrace ();
1288
-
1289
- boolean showDialog = PreferencesData .getBoolean ("menu.examples.dialog" , true );
1290
- if (showDialog ) {
1291
- return ;
1292
- }
1293
-
1294
1288
// Avoid call twice from "Editor.buildMenuBar"
1295
1289
if (menu .isLoading ()) return ;
1296
1290
@@ -1564,6 +1558,7 @@ protected void onIndexesUpdated() throws Exception {
1564
1558
1565
1559
public void rebuildBoardsMenu () throws Exception {
1566
1560
boardsCustomMenus = new LinkedList <>();
1561
+ boardsCustomMenusLoading = true ;
1567
1562
1568
1563
// Execute in backgroud thread, no need UI thread because no rendering needed
1569
1564
menuExecutor .execute (() -> {
@@ -1689,6 +1684,8 @@ public void actionPerformed(ActionEvent actionevent) {
1689
1684
menuItemToClick .getAction ().actionPerformed (new ActionEvent (this , -1 , "" ));
1690
1685
}
1691
1686
1687
+ boardsCustomMenusLoading = false ;
1688
+
1692
1689
});
1693
1690
1694
1691
}
@@ -1717,7 +1714,10 @@ public void actionPerformed(ActionEvent actionevent) {
1717
1714
BaseNoGui .selectBoard ((TargetBoard ) getValue ("b" ));
1718
1715
filterVisibilityOfSubsequentBoardMenus (boardsCustomMenus , (TargetBoard ) getValue ("b" ), 1 );
1719
1716
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
+
1721
1721
rebuildImportMenu (Editor .importMenu );
1722
1722
rebuildExamplesMenu (Editor .examplesMenu );
1723
1723
rebuildProgrammerMenu ();
0 commit comments