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