Skip to content
Snippets Groups Projects
Commit 5802fb0f authored by apriestman's avatar apriestman
Browse files

Only hold controllersByCaseLock when using controllersByCase.

Prevent NPE in DrawableFile.
parent 89fb28da
Branches
Tags
No related merge requests found
...@@ -192,12 +192,15 @@ public static ImageGalleryController getController(Case theCase) { ...@@ -192,12 +192,15 @@ public static ImageGalleryController getController(Case theCase) {
* @param theCase The case. * @param theCase The case.
*/ */
static void shutDownController(Case theCase) { static void shutDownController(Case theCase) {
ImageGalleryController controller = null;
synchronized (controllersByCaseLock) { synchronized (controllersByCaseLock) {
if (controllersByCase.containsKey(theCase.getName())) { if (controllersByCase.containsKey(theCase.getName())) {
ImageGalleryController controller = controllersByCase.remove(theCase.getName()); controller = controllersByCase.remove(theCase.getName());
controller.shutDown();
} }
} }
if (controller != null) {
controller.shutDown();
}
} }
/** /**
......
...@@ -105,8 +105,15 @@ public static DrawableFile create(Long fileID, boolean analyzed) throws TskCoreE ...@@ -105,8 +105,15 @@ public static DrawableFile create(Long fileID, boolean analyzed) throws TskCoreE
protected DrawableFile(AbstractFile file, Boolean analyzed) { protected DrawableFile(AbstractFile file, Boolean analyzed) {
this.analyzed = new SimpleBooleanProperty(analyzed); this.analyzed = new SimpleBooleanProperty(analyzed);
this.file = file; this.file = file;
categoryManager = ImageGalleryController.getController(Case.getCurrentCase()).getCategoryManager(); ImageGalleryController controllerForCase = ImageGalleryController.getController(Case.getCurrentCase());
if (controllerForCase != null) {
categoryManager = ImageGalleryController.getController(Case.getCurrentCase()).getCategoryManager();
} else {
// If getting the controller fails it means the case is currently closing. No need to
// print an error.
categoryManager = null;
}
} }
public abstract boolean isVideo(); public abstract boolean isVideo();
...@@ -246,6 +253,12 @@ public SimpleObjectProperty<TagName> categoryProperty() { ...@@ -246,6 +253,12 @@ public SimpleObjectProperty<TagName> categoryProperty() {
* Update the category property. * Update the category property.
*/ */
private void updateCategory() { private void updateCategory() {
// This only happens when a DrawableFile is created while the case is closing. No need
// to display the error message.
if (categoryManager == null) {
return;
}
try { try {
List<ContentTag> contentTags = getContentTags(); List<ContentTag> contentTags = getContentTags();
TagName tag = null; TagName tag = null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment