Skip to content

Commit a0d44ca

Browse files
rebuildProgrammerMenu: Handle no current board
This can happen when a board was selected, but the platform it lives in was removed (or probably also when the board is removed from the platform). Before this commit, this would give a NullPointerException, now it just shows an empty programmers menu. There appears to be some more weirdness (lacking a selected board, all custom menus are visible), see arduino#10887 for that.
1 parent a056a5f commit a0d44ca

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)