Merge pull request #1968 from millmanorama/fix-thumbnail-generation-progressbar-bug-on-case-change

make sure to kill the progressHandle and timer even if exception is thrown, eg, when case is closed
This commit is contained in:
Richard Cordovano 2016-02-12 13:42:47 -05:00
commit ce264d939d
2 changed files with 19 additions and 18 deletions

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011 Basis Technology Corp. * Copyright 2011-16 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -95,17 +95,19 @@ class ThumbnailViewNode extends FilterNode {
super.done(); super.done();
try { try {
iconCache = new SoftReference<>(super.get()); iconCache = new SoftReference<>(super.get());
progressHandle.finish();
fireIconChange(); fireIconChange();
} catch (InterruptedException | ExecutionException ex) {
Logger.getLogger(ThumbnailViewNode.class.getName()).log(Level.SEVERE, "Error getting thumbnail icon", ex); //NON-NLS
} finally {
progressHandle.finish();
if (timer != null) { if (timer != null) {
timer.stop(); timer.stop();
timer = null; timer = null;
}
} catch (InterruptedException | ExecutionException ex) {
Logger.getLogger(ThumbnailViewNode.class.getName()).log(Level.SEVERE, "Error getting thumbnail icon", ex); //NON-NLS
} }
swingWorker = null; swingWorker = null;
} }
}
}; };
swingWorker.execute(); swingWorker.execute();
} }

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2015 Basis Technology Corp. * Copyright 2015-16 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -18,6 +18,7 @@
*/ */
package org.sleuthkit.autopsy.coreutils; package org.sleuthkit.autopsy.coreutils;
import com.google.common.io.Files;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -94,20 +95,18 @@ public class VideoUtils {
static BufferedImage generateVideoThumbnail(AbstractFile file, int iconSize) { static BufferedImage generateVideoThumbnail(AbstractFile file, int iconSize) {
java.io.File tempFile = getTempVideoFile(file); java.io.File tempFile = getTempVideoFile(file);
try {
if (tempFile.exists() == false || tempFile.length() < file.getSize()) { if (tempFile.exists() == false || tempFile.length() < file.getSize()) {
com.google.common.io.Files.createParentDirs(tempFile);
ProgressHandle progress = ProgressHandleFactory.createHandle(NbBundle.getMessage(VideoUtils.class, "VideoUtils.genVideoThumb.progress.text", file.getName())); ProgressHandle progress = ProgressHandleFactory.createHandle(NbBundle.getMessage(VideoUtils.class, "VideoUtils.genVideoThumb.progress.text", file.getName()));
progress.start(100); progress.start(100);
try { try {
Files.createParentDirs(tempFile);
ContentUtils.writeToFile(file, tempFile, progress, null, true); ContentUtils.writeToFile(file, tempFile, progress, null, true);
} catch (IOException ex) { } catch (IOException ex) {
LOGGER.log(Level.WARNING, "Error buffering file", ex); //NON-NLS LOGGER.log(Level.WARNING, "Error buffering file to disk", ex); //NON-NLS
} return null;
} finally {
progress.finish(); progress.finish();
} }
} catch (IOException ex) {
return null;
} }
VideoCapture videoFile = new VideoCapture(); // will contain the video VideoCapture videoFile = new VideoCapture(); // will contain the video