diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java index 18d988e8222..ab6781fb351 100644 --- a/app/src/processing/app/Base.java +++ b/app/src/processing/app/Base.java @@ -1433,7 +1433,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 @@ -1643,7 +1643,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);