Skip to content

Commit 11e439c

Browse files
committed
ShadowMenu: avoid NPE when child module is null
See: http://fiji.sc/bugzilla/show_bug.cgi?id=944 Of course, it is quite odd for the child module to be null. It may be a symptom of a larger issue. But it's still better not to throw NPE here.
1 parent 2d16186 commit 11e439c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -529,14 +529,15 @@ private ShadowMenu addChild(final ModuleInfo info, final int depth) {
529529
if (!leaf) child.addChild(info, depth + 1);
530530
else if (existingChild != null) {
531531
if (log != null) {
532-
if (info.getPriority() == existingChild.getModuleInfo().getPriority()) {
532+
final ModuleInfo childInfo = existingChild.getModuleInfo();
533+
if (childInfo != null && info.getPriority() == childInfo.getPriority())
534+
{
533535
log.warn("ShadowMenu: menu item already exists:\n\texisting: " +
534-
existingChild.getModuleInfo() + "\n\t ignored: " + info);
536+
childInfo + "\n\t ignored: " + info);
535537
}
536538
else {
537539
log.debug("ShadowMenu: higher-priority menu item already exists:\n" +
538-
"\texisting: " + existingChild.getModuleInfo() + "\n\t ignored: " +
539-
info);
540+
"\texisting: " + childInfo + "\n\t ignored: " + info);
540541
}
541542
}
542543
}

0 commit comments

Comments
 (0)