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