Create timeline controller only at case open

This commit is contained in:
apriestman 2021-03-17 10:08:58 -04:00 committed by rcordovano
parent b55a3882bd
commit d0ec4dd613

View File

@ -49,19 +49,19 @@ public class TimeLineModule {
} }
/** /**
* Get instance of the controller for the current case * Get instance of the controller for the current case.
* The controller instance is initialized from a case open event.
* *
* @return the controller for the current case. * @return the controller for the current case.
* *
* @throws NoCurrentCaseException If there is no case open.
* @throws TskCoreException If there was a problem accessing the case * @throws TskCoreException If there was a problem accessing the case
* database. * database.
* *
*/ */
public static TimeLineController getController() throws NoCurrentCaseException, TskCoreException { public static TimeLineController getController() throws TskCoreException {
synchronized (controllerLock) { synchronized (controllerLock) {
if (controller == null) { if (controller == null) {
controller = new TimeLineController(Case.getCurrentCaseThrows()); throw new TskCoreException("Timeline controller not initialized");
} }
return controller; return controller;
} }
@ -100,13 +100,22 @@ public class TimeLineModule {
} }
controller = null; controller = null;
} }
} else {
// Case is opening - create the controller now
synchronized (controllerLock) {
try {
controller = new TimeLineController(Case.getCurrentCaseThrows());
} catch (TskCoreException | NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Error creating Timeline controller", ex);
}
}
} }
} else { } else {
try { try {
getController().handleCaseEvent(evt); getController().handleCaseEvent(evt);
} catch (NoCurrentCaseException ignored) {
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
logger.log(Level.SEVERE, "Error handling application event", ex); // The call to getController() will only fail due to case closing, so do
// not record the error.
} }
} }
} }
@ -121,12 +130,9 @@ public class TimeLineModule {
public void propertyChange(PropertyChangeEvent evt) { public void propertyChange(PropertyChangeEvent evt) {
try { try {
getController().handleIngestModuleEvent(evt); getController().handleIngestModuleEvent(evt);
} catch (NoCurrentCaseException ex) {
// ignore
return;
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
MessageNotifyUtil.Message.error("Error creating timeline controller."); // The call to getController() will only fail due to case closing, so do
logger.log(Level.SEVERE, "Error creating timeline controller", ex); // not record the error.
} }
} }
} }