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