File tree 2 files changed +19
-2
lines changed
2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -1422,7 +1422,7 @@ public void rebuildRecentBoardsMenu() throws Exception {
1422
1422
boardMenuScroller .setTopFixedCount (3 + index );
1423
1423
}
1424
1424
1425
- public void onBoardOrPortChange () {
1425
+ public synchronized void onBoardOrPortChange () {
1426
1426
BaseNoGui .onBoardOrPortChange ();
1427
1427
1428
1428
// reload keywords when package/platform changes
@@ -1632,7 +1632,20 @@ private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
1632
1632
@ SuppressWarnings ("serial" )
1633
1633
Action action = new AbstractAction (board .getName ()) {
1634
1634
public void actionPerformed (ActionEvent actionevent ) {
1635
- selectTargetBoard ((TargetBoard ) getValue ("b" ));
1635
+ new Thread ()
1636
+ {
1637
+ public void run () {
1638
+ if (activeEditor != null && activeEditor .isCompiling ()) {
1639
+ // block until isCompiling becomes false, but aboid blocking the UI
1640
+ while (activeEditor .isCompiling ()) {
1641
+ try {
1642
+ Thread .sleep (100 );
1643
+ } catch (InterruptedException e ) {}
1644
+ }
1645
+ }
1646
+ selectTargetBoard ((TargetBoard ) getValue ("b" ));
1647
+ }
1648
+ }.start ();
1636
1649
}
1637
1650
};
1638
1651
action .putValue ("b" , board );
Original file line number Diff line number Diff line change @@ -2151,6 +2151,10 @@ public void run() {
2151
2151
}
2152
2152
}
2153
2153
2154
+ public boolean isCompiling () {
2155
+ return uploading ;
2156
+ }
2157
+
2154
2158
private void resumeOrCloseSerialMonitor () {
2155
2159
// Return the serial monitor window to its initial state
2156
2160
if (serialMonitor != null ) {
You can’t perform that action at this time.
0 commit comments