1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-19 08:52:15 +01:00

Show a helpful message when no Port is selected

This commit is contained in:
PaulStoffregen 2018-08-31 03:52:51 -07:00 committed by Cristian Maglie
parent 5f9ff25b3c
commit 4ccf9bbd90
2 changed files with 14 additions and 1 deletions

View File

@ -709,6 +709,10 @@ public class SketchController {
UploaderUtils uploaderInstance = new UploaderUtils();
Uploader uploader = uploaderInstance.getUploaderByPreferences(false);
if (uploader == null) {
editor.statusError(tr("Please select a Port before Upload"));
return false;
}
EditorConsole.setCurrentEditorConsole(editor.console);

View File

@ -50,7 +50,16 @@ public class UploaderUtils {
BoardPort boardPort = null;
if (!noUploadPort) {
boardPort = BaseNoGui.getDiscoveryManager().find(PreferencesData.get("serial.port"));
String port = PreferencesData.get("serial.port");
if (port == null || port.isEmpty()) {
return null;
}
boardPort = BaseNoGui.getDiscoveryManager().find(port);
//if (boardPort == null) {
// Is there ever a reason to attempt upload when
// the Port is not found by DiscoveryManager?
//return null;
//}
}
return new UploaderFactory().newUploader(target.getBoards().get(board), boardPort, noUploadPort);