File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 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 {
14221422 boardMenuScroller .setTopFixedCount (3 + index );
14231423 }
14241424
1425- public void onBoardOrPortChange () {
1425+ public synchronized void onBoardOrPortChange () {
14261426 BaseNoGui .onBoardOrPortChange ();
14271427
14281428 // reload keywords when package/platform changes
@@ -1632,7 +1632,20 @@ private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
16321632 @ SuppressWarnings ("serial" )
16331633 Action action = new AbstractAction (board .getName ()) {
16341634 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 ();
16361649 }
16371650 };
16381651 action .putValue ("b" , board );
Original file line number Diff line number Diff line change @@ -2151,6 +2151,10 @@ public void run() {
21512151 }
21522152 }
21532153
2154+ public boolean isCompiling () {
2155+ return uploading ;
2156+ }
2157+
21542158 private void resumeOrCloseSerialMonitor () {
21552159 // Return the serial monitor window to its initial state
21562160 if (serialMonitor != null ) {
You can’t perform that action at this time.
0 commit comments