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