Skip to content

Commit 61e12d5

Browse files
rebuildProgrammerMenu: Handle no current board
This can happen happen in some unlikely cases (such as when renaming a platform in a way that breaks the "select a board when none is selected logic"). Even though a board should always be selected, code should still handle no selected board gracefully (rather than raising a NullPointerException like this used to do). See arduino#10887 for the underlying issue that caused no board to be selected.
1 parent a056a5f commit 61e12d5

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

app/src/processing/app/Base.java

+12-10
Original file line numberDiff line numberDiff line change
@@ -1702,18 +1702,20 @@ public void rebuildProgrammerMenu() {
17021702
ButtonGroup group = new ButtonGroup();
17031703

17041704
TargetBoard board = BaseNoGui.getTargetBoard();
1705-
TargetPlatform boardPlatform = board.getContainerPlatform();
1706-
TargetPlatform corePlatform = null;
1705+
if (board != null) {
1706+
TargetPlatform boardPlatform = board.getContainerPlatform();
1707+
TargetPlatform corePlatform = null;
17071708

1708-
String core = board.getPreferences().get("build.core");
1709-
if (core != null && core.contains(":")) {
1710-
String[] split = core.split(":", 2);
1711-
corePlatform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
1712-
}
1709+
String core = board.getPreferences().get("build.core");
1710+
if (core != null && core.contains(":")) {
1711+
String[] split = core.split(":", 2);
1712+
corePlatform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
1713+
}
17131714

1714-
addProgrammersForPlatform(boardPlatform, programmerMenus, group);
1715-
if (corePlatform != null)
1716-
addProgrammersForPlatform(corePlatform, programmerMenus, group);
1715+
addProgrammersForPlatform(boardPlatform, programmerMenus, group);
1716+
if (corePlatform != null)
1717+
addProgrammersForPlatform(corePlatform, programmerMenus, group);
1718+
}
17171719

17181720
if (programmerMenus.isEmpty()) {
17191721
JMenuItem item = new JMenuItem(tr("No programmers available for this board"));

0 commit comments

Comments
 (0)