Only hold controllersByCaseLock when using controllersByCase.

Prevent NPE in DrawableFile.
This commit is contained in:
apriestman 2021-03-02 09:38:35 -05:00
parent 89fb28da30
commit 5802fb0faa
2 changed files with 20 additions and 4 deletions

View File

@ -192,12 +192,15 @@ public final class ImageGalleryController {
* @param theCase The case.
*/
static void shutDownController(Case theCase) {
ImageGalleryController controller = null;
synchronized (controllersByCaseLock) {
if (controllersByCase.containsKey(theCase.getName())) {
ImageGalleryController controller = controllersByCase.remove(theCase.getName());
controller.shutDown();
controller = controllersByCase.remove(theCase.getName());
}
}
if (controller != null) {
controller.shutDown();
}
}
/**

View File

@ -106,7 +106,14 @@ public abstract class DrawableFile {
this.analyzed = new SimpleBooleanProperty(analyzed);
this.file = file;
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();
@ -246,6 +253,12 @@ public abstract class DrawableFile {
* Update the category property.
*/
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 {
List<ContentTag> contentTags = getContentTags();
TagName tag = null;