@@ -1291,7 +1291,7 @@ public void rebuildExamplesMenu(JMenu menu) {
1291
1291
private static String priorPlatformFolder ;
1292
1292
private static boolean newLibraryImported ;
1293
1293
1294
- public void onBoardOrPortChange () {
1294
+ public synchronized void onBoardOrPortChange () {
1295
1295
BaseNoGui .onBoardOrPortChange ();
1296
1296
1297
1297
// reload keywords when package/platform changes
@@ -1490,12 +1490,26 @@ private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
1490
1490
@ SuppressWarnings ("serial" )
1491
1491
Action action = new AbstractAction (board .getName ()) {
1492
1492
public void actionPerformed (ActionEvent actionevent ) {
1493
- BaseNoGui .selectBoard ((TargetBoard ) getValue ("b" ));
1494
- filterVisibilityOfSubsequentBoardMenus (boardsCustomMenus , (TargetBoard ) getValue ("b" ), 1 );
1495
1493
1496
- onBoardOrPortChange ();
1497
- rebuildImportMenu (Editor .importMenu );
1498
- rebuildExamplesMenu (Editor .examplesMenu );
1494
+ new Thread ()
1495
+ {
1496
+ public void run () {
1497
+ if (activeEditor != null && activeEditor .isCompiling ()) {
1498
+ // block until isCompiling becomes false, but aboid blocking the UI
1499
+ while (activeEditor .isCompiling ()) {
1500
+ try {
1501
+ Thread .sleep (100 );
1502
+ } catch (InterruptedException e ) {}
1503
+ }
1504
+ }
1505
+
1506
+ BaseNoGui .selectBoard ((TargetBoard ) getValue ("b" ));
1507
+ filterVisibilityOfSubsequentBoardMenus (boardsCustomMenus , (TargetBoard ) getValue ("b" ), 1 );
1508
+ onBoardOrPortChange ();
1509
+ rebuildImportMenu (Editor .importMenu );
1510
+ rebuildExamplesMenu (Editor .examplesMenu );
1511
+ }
1512
+ }.start ();
1499
1513
}
1500
1514
};
1501
1515
action .putValue ("b" , board );
0 commit comments