Skip to content

Commit d0ec4dd

Browse files
APriestmanrcordovano
authored andcommitted
Create timeline controller only at case open
1 parent b55a388 commit d0ec4dd

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

Core/src/org/sleuthkit/autopsy/timeline/TimeLineModule.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@ private TimeLineModule() {
4949
}
5050

5151
/**
52-
* Get instance of the controller for the current case
52+
* Get instance of the controller for the current case.
53+
* The controller instance is initialized from a case open event.
5354
*
5455
* @return the controller for the current case.
5556
*
56-
* @throws NoCurrentCaseException If there is no case open.
5757
* @throws TskCoreException If there was a problem accessing the case
5858
* database.
5959
*
6060
*/
61-
public static TimeLineController getController() throws NoCurrentCaseException, TskCoreException {
61+
public static TimeLineController getController() throws TskCoreException {
6262
synchronized (controllerLock) {
6363
if (controller == null) {
64-
controller = new TimeLineController(Case.getCurrentCaseThrows());
64+
throw new TskCoreException("Timeline controller not initialized");
6565
}
6666
return controller;
6767
}
@@ -100,13 +100,22 @@ public void propertyChange(PropertyChangeEvent evt) {
100100
}
101101
controller = null;
102102
}
103+
} else {
104+
// Case is opening - create the controller now
105+
synchronized (controllerLock) {
106+
try {
107+
controller = new TimeLineController(Case.getCurrentCaseThrows());
108+
} catch (TskCoreException | NoCurrentCaseException ex) {
109+
logger.log(Level.SEVERE, "Error creating Timeline controller", ex);
110+
}
111+
}
103112
}
104113
} else {
105114
try {
106115
getController().handleCaseEvent(evt);
107-
} catch (NoCurrentCaseException ignored) {
108116
} catch (TskCoreException ex) {
109-
logger.log(Level.SEVERE, "Error handling application event", ex);
117+
// The call to getController() will only fail due to case closing, so do
118+
// not record the error.
110119
}
111120
}
112121
}
@@ -121,12 +130,9 @@ static private class IngestModuleEventListener implements PropertyChangeListener
121130
public void propertyChange(PropertyChangeEvent evt) {
122131
try {
123132
getController().handleIngestModuleEvent(evt);
124-
} catch (NoCurrentCaseException ex) {
125-
// ignore
126-
return;
127133
} catch (TskCoreException ex) {
128-
MessageNotifyUtil.Message.error("Error creating timeline controller.");
129-
logger.log(Level.SEVERE, "Error creating timeline controller", ex);
134+
// The call to getController() will only fail due to case closing, so do
135+
// not record the error.
130136
}
131137
}
132138
}

0 commit comments

Comments
 (0)