Skip to content

Commit

Permalink
Avoid board change during compilation/upload
Browse files Browse the repository at this point in the history
By threading the boardChange callback we can busy wait until
the compilation/upload phase has ended and change the board when done.

Fixes #6035
  • Loading branch information
facchinm committed Jul 19, 2019
1 parent d44e6ce commit 25489f1
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -1422,7 +1422,7 @@ public void rebuildRecentBoardsMenu() throws Exception {
boardMenuScroller.setTopFixedCount(3 + index);
}

public void onBoardOrPortChange() {
public synchronized void onBoardOrPortChange() {
BaseNoGui.onBoardOrPortChange();

// reload keywords when package/platform changes
Expand Down Expand Up @@ -1632,7 +1632,20 @@ private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
@SuppressWarnings("serial")
Action action = new AbstractAction(board.getName()) {
public void actionPerformed(ActionEvent actionevent) {
selectTargetBoard((TargetBoard) getValue("b"));
new Thread()
{
public void run() {
if (activeEditor != null && activeEditor.isUploading()) {
// block until isUploading becomes false, but aboid blocking the UI
while (activeEditor.isUploading()) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {}
}
}
selectTargetBoard((TargetBoard) getValue("b"));
}
}.start();
}
};
action.putValue("b", board);
Expand Down

0 comments on commit 25489f1

Please sign in to comment.