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