From 1d376eab3959cbfc59953062d9a5863ce871c98f Mon Sep 17 00:00:00 2001 From: Greg DiCristofaro <gregd@basistech.com> Date: Mon, 14 Nov 2022 15:17:56 -0500 Subject: [PATCH] fixes for javafx, keyword search, and image gallery issue --- .../org/sleuthkit/autopsy/core/Installer.java | 7 +++++ .../sleuthkit/autopsy/coreutils/XMLUtil.java | 5 ++++ .../gui/drawableviews/GroupPane.java | 30 ++++++++++--------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/core/Installer.java b/Core/src/org/sleuthkit/autopsy/core/Installer.java index 434e8798a5..24c40e9967 100644 --- a/Core/src/org/sleuthkit/autopsy/core/Installer.java +++ b/Core/src/org/sleuthkit/autopsy/core/Installer.java @@ -263,6 +263,13 @@ private static void initJavaFx() { //initialize java fx if exists System.setProperty("javafx.macosx.embedded", "true"); try { + + // Due to a lingering issue https://bugs.openjdk.org/browse/JDK-8223377 where glass.dll from java 8 gets loaded instead of the java 17 one. + String javaLibraryPath = "java.library.path"; + String jvmBinPathStr = Paths.get(System.getProperty("java.home"), "bin").toAbsolutePath().toString(); + String path = System.getProperty(javaLibraryPath); + System.setProperty(javaLibraryPath, StringUtils.isBlank(path) ? jvmBinPathStr : jvmBinPathStr + File.pathSeparator + path); + // Creating a JFXPanel initializes JavaFX new JFXPanel(); Platform.setImplicitExit(false); diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/XMLUtil.java b/Core/src/org/sleuthkit/autopsy/coreutils/XMLUtil.java index 4323753515..eb3c16e1c1 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/XMLUtil.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/XMLUtil.java @@ -55,6 +55,11 @@ */ public class XMLUtil { + static { + // this is to ensure using xalan for the transformer factory: https://stackoverflow.com/a/64364531/2375948 + System.setProperty("javax.xml.transform.TransformerFactory","com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl"); + } + private static DocumentBuilder getDocumentBuilder() throws ParserConfigurationException { // See JIRA-6958 for details about class loading and jaxb. ClassLoader original = Thread.currentThread().getContextClassLoader(); diff --git a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/GroupPane.java b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/GroupPane.java index fed02ac6e4..4a4665e1ff 100644 --- a/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/GroupPane.java +++ b/ImageGallery/src/org/sleuthkit/autopsy/imagegallery/gui/drawableviews/GroupPane.java @@ -46,6 +46,7 @@ import javafx.beans.property.ReadOnlyObjectProperty; import javafx.beans.property.ReadOnlyObjectWrapper; import javafx.beans.property.SimpleObjectProperty; +import javafx.beans.value.ChangeListener; import javafx.beans.value.ObservableValue; import javafx.collections.ObservableList; import javafx.event.ActionEvent; @@ -662,24 +663,25 @@ private class DrawableCell extends GridCell<Long> { private final DrawableTile tile = new DrawableTile(GroupPane.this, controller); - DrawableCell() { - itemProperty().addListener((ObservableValue<? extends Long> observable, Long oldValue, Long newValue) -> { - if (oldValue != null) { - cellMap.remove(oldValue, DrawableCell.this); - tile.setFile(null); + protected final ChangeListener<Long> changeListener = (ObservableValue<? extends Long> observable, Long oldValue, Long newValue) -> { + if ((oldValue == null && newValue == null) || (oldValue != null && newValue != null && oldValue.equals(newValue))) { + // if no change, do nothing + return; + } + + DrawableCell oldValueCell = oldValue == null ? null : cellMap.remove(oldValue); + if (oldValueCell != null) { + // remove change listener to get garbage collected + oldValueCell.itemProperty().removeListener(oldValueCell.changeListener); } + if (newValue != null) { - if (cellMap.containsKey(newValue)) { - if (tile != null) { - // Clear out the old value to prevent out-of-date listeners - // from activating. - cellMap.get(newValue).tile.setFile(null); - } - } cellMap.put(newValue, DrawableCell.this); } - }); - + }; + + DrawableCell() { + itemProperty().addListener(changeListener); setGraphic(tile); } -- GitLab