Merge pull request #1305 from millmanorama/grouptreecell_npe_fix

fix NPE in GroupTreeCell by not removing null Listener
This commit is contained in:
Richard Cordovano 2015-06-04 09:45:33 -04:00
commit c6b2e936dd
2 changed files with 11 additions and 8 deletions

View File

@ -22,8 +22,8 @@ import org.sleuthkit.autopsy.coreutils.Logger;
/** /**
* *
* The {@link OnStart} annotation tells NetBeans to invoke this class's * The {@link org.openide.modules.OnStart} annotation tells NetBeans to invoke
* {@link OnStart#run()} method * this class's {@link OnStart#run()} method
*/ */
@org.openide.modules.OnStart @org.openide.modules.OnStart
public class OnStart implements Runnable { public class OnStart implements Runnable {
@ -31,7 +31,7 @@ public class OnStart implements Runnable {
static private final Logger LOGGER = Logger.getLogger(OnStart.class.getName()); static private final Logger LOGGER = Logger.getLogger(OnStart.class.getName());
/** /**
*
* *
* This method is invoked by virtue of the {@link OnStart} annotation on the * This method is invoked by virtue of the {@link OnStart} annotation on the
* {@link ImageGalleryModule} class * {@link ImageGalleryModule} class

View File

@ -18,6 +18,7 @@
*/ */
package org.sleuthkit.autopsy.imagegallery.gui.navpanel; package org.sleuthkit.autopsy.imagegallery.gui.navpanel;
import java.util.Objects;
import static java.util.Objects.isNull; import static java.util.Objects.isNull;
import java.util.Optional; import java.util.Optional;
import javafx.application.Platform; import javafx.application.Platform;
@ -66,11 +67,13 @@ class GroupTreeCell extends TreeCell<TreeNode> {
@Override @Override
protected synchronized void updateItem(final TreeNode tNode, boolean empty) { protected synchronized void updateItem(final TreeNode tNode, boolean empty) {
//if there was a previous group, remove the listener //if there was a previous group, remove the listener
if (Objects.nonNull(listener)) {
Optional.ofNullable(getItem()) Optional.ofNullable(getItem())
.map(TreeNode::getGroup) .map(TreeNode::getGroup)
.ifPresent((DrawableGroup t) -> { .ifPresent((DrawableGroup t) -> {
t.fileIds().removeListener(listener); t.fileIds().removeListener(listener);
}); });
}
super.updateItem(tNode, empty); super.updateItem(tNode, empty);