@@ -1328,7 +1328,7 @@ public void rebuildExamplesMenu(JMenu menu) {
1328
1328
private static String priorPlatformFolder ;
1329
1329
private static boolean newLibraryImported ;
1330
1330
1331
- public void onBoardOrPortChange () {
1331
+ public synchronized void onBoardOrPortChange () {
1332
1332
BaseNoGui .onBoardOrPortChange ();
1333
1333
1334
1334
// reload keywords when package/platform changes
@@ -1527,12 +1527,26 @@ private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
1527
1527
@ SuppressWarnings ("serial" )
1528
1528
Action action = new AbstractAction (board .getName ()) {
1529
1529
public void actionPerformed (ActionEvent actionevent ) {
1530
- BaseNoGui .selectBoard ((TargetBoard ) getValue ("b" ));
1531
- filterVisibilityOfSubsequentBoardMenus (boardsCustomMenus , (TargetBoard ) getValue ("b" ), 1 );
1532
1530
1533
- onBoardOrPortChange ();
1534
- rebuildImportMenu (Editor .importMenu );
1535
- rebuildExamplesMenu (Editor .examplesMenu );
1531
+ new Thread ()
1532
+ {
1533
+ public void run () {
1534
+ if (activeEditor != null && activeEditor .isCompiling ()) {
1535
+ // block until isCompiling becomes false, but aboid blocking the UI
1536
+ while (activeEditor .isCompiling ()) {
1537
+ try {
1538
+ Thread .sleep (100 );
1539
+ } catch (InterruptedException e ) {}
1540
+ }
1541
+ }
1542
+
1543
+ BaseNoGui .selectBoard ((TargetBoard ) getValue ("b" ));
1544
+ filterVisibilityOfSubsequentBoardMenus (boardsCustomMenus , (TargetBoard ) getValue ("b" ), 1 );
1545
+ onBoardOrPortChange ();
1546
+ rebuildImportMenu (Editor .importMenu );
1547
+ rebuildExamplesMenu (Editor .examplesMenu );
1548
+ }
1549
+ }.start ();
1536
1550
}
1537
1551
};
1538
1552
action .putValue ("b" , board );
0 commit comments