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 @@ -1398,7 +1398,7 @@ public void rebuildRecentBoardsMenu() throws Exception {
1398
1398
boardMenuScroller .setTopFixedCount (3 + index );
1399
1399
}
1400
1400
1401
- public void onBoardOrPortChange () {
1401
+ public synchronized void onBoardOrPortChange () {
1402
1402
BaseNoGui .onBoardOrPortChange ();
1403
1403
1404
1404
// reload keywords when package/platform changes
@@ -1605,7 +1605,20 @@ private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
1605
1605
@ SuppressWarnings ("serial" )
1606
1606
Action action = new AbstractAction (board .getName ()) {
1607
1607
public void actionPerformed (ActionEvent actionevent ) {
1608
- selectTargetBoard ((TargetBoard ) getValue ("b" ));
1608
+ new Thread ()
1609
+ {
1610
+ public void run () {
1611
+ if (activeEditor != null && activeEditor .isCompiling ()) {
1612
+ // block until isCompiling becomes false, but aboid blocking the UI
1613
+ while (activeEditor .isCompiling ()) {
1614
+ try {
1615
+ Thread .sleep (100 );
1616
+ } catch (InterruptedException e ) {}
1617
+ }
1618
+ }
1619
+ selectTargetBoard ((TargetBoard ) getValue ("b" ));
1620
+ }
1621
+ }.start ();
1609
1622
}
1610
1623
};
1611
1624
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