1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-02-26 20:54:22 +01:00

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
This commit is contained in:
Martino Facchin 2017-03-22 11:46:41 +01:00
parent 70d5537fb0
commit 97fd81ac0c

View File

@ -1438,7 +1438,7 @@ public class Base {
boardMenuScroller.setTopFixedCount(3 + index);
}
public void onBoardOrPortChange() {
public synchronized void onBoardOrPortChange() {
BaseNoGui.onBoardOrPortChange();
// reload keywords when package/platform changes
@ -1676,7 +1676,20 @@ public class Base {
@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);