Skip to content

Commit 12b1bea

Browse files
committed
Only warn about duplicate menu entries if priorities are equal
When we try to add menu items with the same path and their priorities differ, we should not complain (the higher-priority one was already added in that case, so we do not have to replace any existing item). Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 9f527af commit 12b1bea

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main/java/org/scijava/menu/ShadowMenu.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,8 +530,15 @@ private ShadowMenu addChild(final ModuleInfo info, final int depth) {
530530
if (!leaf) child.addChild(info, depth + 1);
531531
else if (existingChild != null) {
532532
if (log != null) {
533-
log.warn("ShadowMenu: menu item already exists:\n\texisting: " +
534-
existingChild.getModuleInfo() + "\n\t ignored: " + info);
533+
if (info.getPriority() == existingChild.getModuleInfo().getPriority()) {
534+
log.warn("ShadowMenu: menu item already exists:\n\texisting: " +
535+
existingChild.getModuleInfo() + "\n\t ignored: " + info);
536+
}
537+
else {
538+
log.debug("ShadowMenu: higher-priority menu item already exists:\n" +
539+
"\texisting: " + existingChild.getModuleInfo() + "\n\t ignored: " +
540+
info);
541+
}
535542
}
536543
}
537544
return child;

0 commit comments

Comments
 (0)