Skip to content

Commit 1a21864

Browse files
author
jantje
committed
#1426 just select a board if none has been found
This also makes that the first time you create a project a board is selected
1 parent cdfd191 commit 1a21864

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

io.sloeber.core/src/io/sloeber/core/api/BoardDescription.java

+13-5
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,19 @@ public static List<BoardDescription> makeBoardDescriptors(File boardFile) {
310310

311311
public BoardDescription() {
312312
File boardsFile = new File(myStorageNode.get(KEY_LAST_USED_BOARDS_FILE, EMPTY));
313-
myBoardTxtFile = new BoardTxtFile(boardsFile);
314-
myBoardID = myStorageNode.get(KEY_LAST_USED_BOARD, EMPTY);
315-
myUploadPort = myStorageNode.get(KEY_LAST_USED_UPLOAD_PORT, EMPTY);
316-
myProgrammer = myStorageNode.get(KEY_LAST_USED_UPLOAD_PROTOCOL, EMPTY);
317-
myOptions = KeyValue.makeMap(myStorageNode.get(KEY_LAST_USED_BOARD_MENU_OPTIONS, EMPTY));
313+
if (!boardsFile.exists()) {
314+
List<ArduinoPlatformVersion> platforms = BoardsManager.getInstalledPlatforms();
315+
//If you crash on the next line no platform have been installed
316+
ArduinoPlatformVersion platform = platforms.get(0);
317+
myBoardTxtFile = new BoardTxtFile(platform.getBoardsFile());
318+
myBoardID = myBoardTxtFile.getAllBoardIDs().get(0);
319+
} else {
320+
myBoardTxtFile = new BoardTxtFile(boardsFile);
321+
myBoardID = myStorageNode.get(KEY_LAST_USED_BOARD, EMPTY);
322+
myUploadPort = myStorageNode.get(KEY_LAST_USED_UPLOAD_PORT, EMPTY);
323+
myProgrammer = myStorageNode.get(KEY_LAST_USED_UPLOAD_PROTOCOL, EMPTY);
324+
myOptions = KeyValue.makeMap(myStorageNode.get(KEY_LAST_USED_BOARD_MENU_OPTIONS, EMPTY));
325+
}
318326
}
319327

320328
public BoardDescription(BoardDescription srcObject) {

0 commit comments

Comments
 (0)