From 4ccf9bbd906607195e1aa1c4b0853dd6bc2c7f69 Mon Sep 17 00:00:00 2001 From: PaulStoffregen Date: Fri, 31 Aug 2018 03:52:51 -0700 Subject: [PATCH] Show a helpful message when no Port is selected --- app/src/processing/app/SketchController.java | 4 ++++ arduino-core/src/cc/arduino/UploaderUtils.java | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/processing/app/SketchController.java b/app/src/processing/app/SketchController.java index 89f1a3516..392422c59 100644 --- a/app/src/processing/app/SketchController.java +++ b/app/src/processing/app/SketchController.java @@ -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); diff --git a/arduino-core/src/cc/arduino/UploaderUtils.java b/arduino-core/src/cc/arduino/UploaderUtils.java index ec27b4961..c98928ded 100644 --- a/arduino-core/src/cc/arduino/UploaderUtils.java +++ b/arduino-core/src/cc/arduino/UploaderUtils.java @@ -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);