Skip to content

Commit 4ccf9bb

Browse files
PaulStoffregencmaglie
authored andcommitted
Show a helpful message when no Port is selected
1 parent 5f9ff25 commit 4ccf9bb

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

app/src/processing/app/SketchController.java

+4
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,10 @@ private boolean upload(String suggestedClassName, boolean usingProgrammer) throw
709709

710710
UploaderUtils uploaderInstance = new UploaderUtils();
711711
Uploader uploader = uploaderInstance.getUploaderByPreferences(false);
712+
if (uploader == null) {
713+
editor.statusError(tr("Please select a Port before Upload"));
714+
return false;
715+
}
712716

713717
EditorConsole.setCurrentEditorConsole(editor.console);
714718

arduino-core/src/cc/arduino/UploaderUtils.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,16 @@ public Uploader getUploaderByPreferences(boolean noUploadPort) {
5050

5151
BoardPort boardPort = null;
5252
if (!noUploadPort) {
53-
boardPort = BaseNoGui.getDiscoveryManager().find(PreferencesData.get("serial.port"));
53+
String port = PreferencesData.get("serial.port");
54+
if (port == null || port.isEmpty()) {
55+
return null;
56+
}
57+
boardPort = BaseNoGui.getDiscoveryManager().find(port);
58+
//if (boardPort == null) {
59+
// Is there ever a reason to attempt upload when
60+
// the Port is not found by DiscoveryManager?
61+
//return null;
62+
//}
5463
}
5564

5665
return new UploaderFactory().newUploader(target.getBoards().get(board), boardPort, noUploadPort);

0 commit comments

Comments
 (0)