From d7040f78a9c86fdcfaa3567a25340f83ba4d625a Mon Sep 17 00:00:00 2001 From: dragonmacher <48328597+dragonmacher@users.noreply.github.com> Date: Tue, 28 Feb 2023 14:36:44 -0500 Subject: [PATCH] GP-3147 - Fixed file chooser exception on cancel --- .../filechooser/GhidraFileChooser.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/filechooser/GhidraFileChooser.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/filechooser/GhidraFileChooser.java index 84936ab8df..b6a4056f69 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/filechooser/GhidraFileChooser.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/filechooser/GhidraFileChooser.java @@ -187,9 +187,9 @@ public class GhidraFileChooser extends ReusableDialogComponentProvider implement private SwingUpdateManager modelUpdater = new SwingUpdateManager(this::updateDirectoryModels); /** - * The last input component to take focus (the text field or file view). - * - *

This may annoy users that are using the keyboard to perform navigation operations via + * The last input component to take focus (the text field or file view). + * + *

This may annoy users that are using the keyboard to perform navigation operations via * the toolbar buttons, as we will keep putting focus back into the last input item. We * may need a way to set this field to null when the user is working in this fashion. */ @@ -216,7 +216,7 @@ public class GhidraFileChooser extends ReusableDialogComponentProvider implement /** * Constructs a new ghidra file chooser - * + * * @param model the file chooser model * @param parent the parent component */ @@ -681,9 +681,9 @@ public class GhidraFileChooser extends ReusableDialogComponentProvider implement } /** - * Sets the text used in the OK button - * - * @param buttonText the text + * Sets the text used in the OK button + * + * @param buttonText the text */ public void setApproveButtonText(String buttonText) { setOkButtonText(buttonText); @@ -691,7 +691,7 @@ public class GhidraFileChooser extends ReusableDialogComponentProvider implement /** * Sets the tooltip text used in the OK button - * + * * @param tooltipText the tooltip text */ public void setApproveButtonToolTipText(String tooltipText) { @@ -810,10 +810,10 @@ public class GhidraFileChooser extends ReusableDialogComponentProvider implement } // we only get here if the new dir is the current dir and we are not forcing an update - // TODO this code causes unexpected behavior when in 'directories only' mode in that - // this will cause the current directory to change. The behavior can be seen by + // TODO this code causes unexpected behavior when in 'directories only' mode in that + // this will cause the current directory to change. The behavior can be seen by // putting this code back in and then running the tests. No tests are failing with this - // code removed. We are leaving this code here for a couple releases in case we find + // code removed. We are leaving this code here for a couple releases in case we find // a code path that requires it. // setSelectedFileAndUpdateDisplay((isFilesOnly() ? null : directory)); } @@ -876,10 +876,10 @@ public class GhidraFileChooser extends ReusableDialogComponentProvider implement } /** - * Returns the selected file. This can be set either by the programmer via - * {@link #setSelectedFile(File)} or by a user action, such as either typing the + * Returns the selected file. This can be set either by the programmer via + * {@link #setSelectedFile(File)} or by a user action, such as either typing the * filename into the UI or selecting the file from a list in the UI. - * + * * @return the selected file; null if cancelled or no file was selected */ public File getSelectedFile() { @@ -1963,14 +1963,14 @@ public class GhidraFileChooser extends ReusableDialogComponentProvider implement @Override public void run(TaskMonitor monitor) { - if (monitor.isCancelled()) { + if (monitor.isCancelled() || worker.isDisposed()) { return; } run(); Swing.runLater(() -> { - if (!monitor.isCancelled()) { + if (!monitor.isCancelled() && !worker.isDisposed()) { runSwing(); } }); @@ -2180,7 +2180,7 @@ public class GhidraFileChooser extends ReusableDialogComponentProvider implement * size. The list also allows us to clear and set a value in one method call. We are * essentially using this list to hold selected files, where in certain modes, there will only * be a single file selection. - * + * *

The methods on the class are synchronized to ensure thread visibility. */ private class FileList {