Skip to content

Commit 5064075

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 e125797 commit 5064075

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
@@ -1423,7 +1423,7 @@ public void rebuildRecentBoardsMenu() throws Exception {
14231423
boardMenuScroller.setTopFixedCount(3 + index);
14241424
}
14251425

1426-
public void onBoardOrPortChange() {
1426+
public synchronized void onBoardOrPortChange() {
14271427
BaseNoGui.onBoardOrPortChange();
14281428

14291429
// reload keywords when package/platform changes
@@ -1633,7 +1633,20 @@ private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
16331633
@SuppressWarnings("serial")
16341634
Action action = new AbstractAction(board.getName()) {
16351635
public void actionPerformed(ActionEvent actionevent) {
1636-
selectTargetBoard((TargetBoard) getValue("b"));
1636+
new Thread()
1637+
{
1638+
public void run() {
1639+
if (activeEditor != null && activeEditor.isUploading()) {
1640+
// block until isUploading becomes false, but aboid blocking the UI
1641+
while (activeEditor.isUploading()) {
1642+
try {
1643+
Thread.sleep(100);
1644+
} catch (InterruptedException e) {}
1645+
}
1646+
}
1647+
selectTargetBoard((TargetBoard) getValue("b"));
1648+
}
1649+
}.start();
16371650
}
16381651
};
16391652
action.putValue("b", board);

0 commit comments

Comments
 (0)