Skip to content

Commit 97fd81a

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 70d5537 commit 97fd81a

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
@@ -1438,7 +1438,7 @@ public void rebuildRecentBoardsMenu() throws Exception {
14381438
boardMenuScroller.setTopFixedCount(3 + index);
14391439
}
14401440

1441-
public void onBoardOrPortChange() {
1441+
public synchronized void onBoardOrPortChange() {
14421442
BaseNoGui.onBoardOrPortChange();
14431443

14441444
// reload keywords when package/platform changes
@@ -1676,7 +1676,20 @@ private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
16761676
@SuppressWarnings("serial")
16771677
Action action = new AbstractAction(board.getName()) {
16781678
public void actionPerformed(ActionEvent actionevent) {
1679-
selectTargetBoard((TargetBoard) getValue("b"));
1679+
new Thread()
1680+
{
1681+
public void run() {
1682+
if (activeEditor != null && activeEditor.isUploading()) {
1683+
// block until isUploading becomes false, but aboid blocking the UI
1684+
while (activeEditor.isUploading()) {
1685+
try {
1686+
Thread.sleep(100);
1687+
} catch (InterruptedException e) {}
1688+
}
1689+
}
1690+
selectTargetBoard((TargetBoard) getValue("b"));
1691+
}
1692+
}.start();
16801693
}
16811694
};
16821695
action.putValue("b", board);

0 commit comments

Comments
 (0)