Skip to content

Annotate custom menu to avoid name clashing #8880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 18, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Match CustomMenu against unique platform id
platform.getId() gives the same result for derived cores.
Issue #5260 is caused by both cores declaring as `avr`, with the same label but different identifier.
This patch completes the previous one by adding the folder where the core resides to the matching id.
  • Loading branch information
facchinm committed May 15, 2019
commit f385cbef736c60316c8edb68f12cd2494504f3f5
12 changes: 8 additions & 4 deletions app/src/processing/app/Base.java
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,7 @@ public void actionPerformed(ActionEvent actionevent) {
for (TargetPlatform targetPlatform : targetPackage.platforms()) {
for (String customMenuTitle : targetPlatform.getCustomMenus().values()) {
JMenu customMenu = new JMenu(tr(customMenuTitle));
customMenu.putClientProperty("platform", targetPlatform.getId());
customMenu.putClientProperty("platform", getPlatformUniqueId(targetPlatform));
customMenu.putClientProperty("removeOnWindowDeactivation", true);
boardsCustomMenus.add(customMenu);
}
Expand Down Expand Up @@ -1494,6 +1494,10 @@ public void actionPerformed(ActionEvent actionevent) {
}
}

private String getPlatformUniqueId(TargetPlatform platform) {
return platform.getId() + "_" + platform.getFolder();
}

private JRadioButtonMenuItem createBoardMenusAndCustomMenus(
final List<JMenu> boardsCustomMenus, List<JMenuItem> menuItemsToClickAfterStartup,
Map<String, ButtonGroup> buttonGroupsMap,
Expand Down Expand Up @@ -1531,7 +1535,7 @@ public void actionPerformed(ActionEvent actionevent) {
PreferencesMap customMenus = targetPlatform.getCustomMenus();
for (final String menuId : customMenus.keySet()) {
String title = customMenus.get(menuId);
JMenu menu = getBoardCustomMenu(tr(title), targetPlatform.getId());
JMenu menu = getBoardCustomMenu(tr(title), getPlatformUniqueId(targetPlatform));

if (board.hasMenu(menuId)) {
PreferencesMap boardCustomMenu = board.getMenuLabels(menuId);
Expand Down Expand Up @@ -1601,9 +1605,9 @@ private static boolean ifThereAreVisibleItemsOn(JMenu menu) {
return false;
}

private JMenu getBoardCustomMenu(String label, String platform) throws Exception {
private JMenu getBoardCustomMenu(String label, String platformUniqueId) throws Exception {
for (JMenu menu : boardsCustomMenus) {
if (label.equals(menu.getText()) && platform.equals(menu.getClientProperty("platform"))) {
if (label.equals(menu.getText()) && menu.getClientProperty("platform").equals(platformUniqueId)) {
return menu;
}
}
Expand Down