Skip to content

Commit 06cfbbf

Browse files
committed
Annotate custom menu to avoid name clashing
Fixes #5260
1 parent ef8d669 commit 06cfbbf

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

app/src/processing/app/Base.java

+9-10
Original file line numberDiff line numberDiff line change
@@ -1436,17 +1436,16 @@ public void actionPerformed(ActionEvent actionevent) {
14361436
boardMenu.add(new JSeparator());
14371437

14381438
// Generate custom menus for all platforms
1439-
Set<String> customMenusTitles = new LinkedHashSet<>();
14401439
for (TargetPackage targetPackage : BaseNoGui.packages.values()) {
14411440
for (TargetPlatform targetPlatform : targetPackage.platforms()) {
1442-
customMenusTitles.addAll(targetPlatform.getCustomMenus().values());
1441+
for (String customMenuTitle : targetPlatform.getCustomMenus().values()) {
1442+
JMenu customMenu = new JMenu(tr(customMenuTitle));
1443+
customMenu.putClientProperty("platform", targetPlatform.getId());
1444+
customMenu.putClientProperty("removeOnWindowDeactivation", true);
1445+
boardsCustomMenus.add(customMenu);
1446+
}
14431447
}
14441448
}
1445-
for (String customMenuTitle : customMenusTitles) {
1446-
JMenu customMenu = new JMenu(tr(customMenuTitle));
1447-
customMenu.putClientProperty("removeOnWindowDeactivation", true);
1448-
boardsCustomMenus.add(customMenu);
1449-
}
14501449

14511450
List<JMenuItem> menuItemsToClickAfterStartup = new LinkedList<>();
14521451

@@ -1532,7 +1531,7 @@ public void actionPerformed(ActionEvent actionevent) {
15321531
PreferencesMap customMenus = targetPlatform.getCustomMenus();
15331532
for (final String menuId : customMenus.keySet()) {
15341533
String title = customMenus.get(menuId);
1535-
JMenu menu = getBoardCustomMenu(tr(title));
1534+
JMenu menu = getBoardCustomMenu(tr(title), targetPlatform.getId());
15361535

15371536
if (board.hasMenu(menuId)) {
15381537
PreferencesMap boardCustomMenu = board.getMenuLabels(menuId);
@@ -1595,9 +1594,9 @@ private static boolean ifThereAreVisibleItemsOn(JMenu menu) {
15951594
return false;
15961595
}
15971596

1598-
private JMenu getBoardCustomMenu(String label) throws Exception {
1597+
private JMenu getBoardCustomMenu(String label, String platform) throws Exception {
15991598
for (JMenu menu : boardsCustomMenus) {
1600-
if (label.equals(menu.getText())) {
1599+
if (label.equals(menu.getText()) && platform.equals(menu.getClientProperty("platform"))) {
16011600
return menu;
16021601
}
16031602
}

0 commit comments

Comments
 (0)