Skip to content

Commit 73d5983

Browse files
committed
Avoid board change during compilation/upload
By threading the boardChange callback we can busy wait until the compilation/upload phase has ended and change the board when done. Fixes #6035
1 parent 06306be commit 73d5983

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Diff for: app/src/processing/app/Base.java

+15-2
Original file line numberDiff line numberDiff 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.isUploading()) {
1639+
// block until isUploading becomes false, but aboid blocking the UI
1640+
while (activeEditor.isUploading()) {
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);

0 commit comments

Comments
 (0)