Skip to content

Commit 9b64154

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 be4b8ed commit 9b64154

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
@@ -1426,7 +1426,7 @@ public void rebuildRecentBoardsMenu() throws Exception {
14261426
boardMenuScroller.setTopFixedCount(3 + index);
14271427
}
14281428

1429-
public void onBoardOrPortChange() {
1429+
public synchronized void onBoardOrPortChange() {
14301430
BaseNoGui.onBoardOrPortChange();
14311431

14321432
// reload keywords when package/platform changes
@@ -1636,7 +1636,20 @@ private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
16361636
@SuppressWarnings("serial")
16371637
Action action = new AbstractAction(board.getName()) {
16381638
public void actionPerformed(ActionEvent actionevent) {
1639-
selectTargetBoard((TargetBoard) getValue("b"));
1639+
new Thread()
1640+
{
1641+
public void run() {
1642+
if (activeEditor != null && activeEditor.isUploading()) {
1643+
// block until isUploading becomes false, but aboid blocking the UI
1644+
while (activeEditor.isUploading()) {
1645+
try {
1646+
Thread.sleep(100);
1647+
} catch (InterruptedException e) {}
1648+
}
1649+
}
1650+
selectTargetBoard((TargetBoard) getValue("b"));
1651+
}
1652+
}.start();
16401653
}
16411654
};
16421655
action.putValue("b", board);

0 commit comments

Comments
 (0)