@@ -1309,7 +1309,7 @@ public void rebuildExamplesMenu(JMenu menu) {
1309
1309
private static String priorPlatformFolder ;
1310
1310
private static boolean newLibraryImported ;
1311
1311
1312
- public void onBoardOrPortChange () {
1312
+ public synchronized void onBoardOrPortChange () {
1313
1313
BaseNoGui .onBoardOrPortChange ();
1314
1314
1315
1315
// reload keywords when package/platform changes
@@ -1508,12 +1508,26 @@ private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
1508
1508
@ SuppressWarnings ("serial" )
1509
1509
Action action = new AbstractAction (board .getName ()) {
1510
1510
public void actionPerformed (ActionEvent actionevent ) {
1511
- BaseNoGui .selectBoard ((TargetBoard ) getValue ("b" ));
1512
- filterVisibilityOfSubsequentBoardMenus (boardsCustomMenus , (TargetBoard ) getValue ("b" ), 1 );
1513
1511
1514
- onBoardOrPortChange ();
1515
- rebuildImportMenu (Editor .importMenu );
1516
- rebuildExamplesMenu (Editor .examplesMenu );
1512
+ new Thread ()
1513
+ {
1514
+ public void run () {
1515
+ if (activeEditor != null && activeEditor .isCompiling ()) {
1516
+ // block until isCompiling becomes false, but aboid blocking the UI
1517
+ while (activeEditor .isCompiling ()) {
1518
+ try {
1519
+ Thread .sleep (100 );
1520
+ } catch (InterruptedException e ) {}
1521
+ }
1522
+ }
1523
+
1524
+ BaseNoGui .selectBoard ((TargetBoard ) getValue ("b" ));
1525
+ filterVisibilityOfSubsequentBoardMenus (boardsCustomMenus , (TargetBoard ) getValue ("b" ), 1 );
1526
+ onBoardOrPortChange ();
1527
+ rebuildImportMenu (Editor .importMenu );
1528
+ rebuildExamplesMenu (Editor .examplesMenu );
1529
+ }
1530
+ }.start ();
1517
1531
}
1518
1532
};
1519
1533
action .putValue ("b" , board );
0 commit comments