1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-21 10:52:14 +01:00

Merge pull request #10922 from matthijskooijman/fix-no-board-null-pointer

rebuildProgrammerMenu: Handle no current board
This commit is contained in:
Martino Facchin 2020-12-01 10:06:59 +01:00 committed by GitHub
commit 76dfd0acc2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1702,19 +1702,21 @@ public class Base {
ButtonGroup group = new ButtonGroup();
TargetBoard board = BaseNoGui.getTargetBoard();
TargetPlatform boardPlatform = board.getContainerPlatform();
TargetPlatform corePlatform = null;
if (board != null) {
TargetPlatform boardPlatform = board.getContainerPlatform();
TargetPlatform corePlatform = null;
String core = board.getPreferences().get("build.core");
if (core != null && core.contains(":")) {
String[] split = core.split(":", 2);
corePlatform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
String core = board.getPreferences().get("build.core");
if (core != null && core.contains(":")) {
String[] split = core.split(":", 2);
corePlatform = BaseNoGui.getCurrentTargetPlatformFromPackage(split[0]);
}
addProgrammersForPlatform(boardPlatform, programmerMenus, group);
if (corePlatform != null)
addProgrammersForPlatform(corePlatform, programmerMenus, group);
}
addProgrammersForPlatform(boardPlatform, programmerMenus, group);
if (corePlatform != null)
addProgrammersForPlatform(corePlatform, programmerMenus, group);
if (programmerMenus.isEmpty()) {
JMenuItem item = new JMenuItem(tr("No programmers available for this board"));
item.setEnabled(false);