Skip to content

Ghidra is a software reverse engineering (SRE) framework

Test fixes for Swing access from a script thread

dragonmacher1623f0a0691a
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/table/TableServicePlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/table/TableServicePlugin.java
index 5dc7838e38..51d75c9561 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/table/TableServicePlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/table/TableServicePlugin.java
@@ -36,6 +36,7 @@ import ghidra.framework.model.DomainObjectListener;
import ghidra.framework.plugintool.*;
import ghidra.framework.plugintool.util.PluginStatus;
import ghidra.program.model.listing.Program;
+import ghidra.util.Swing;
import ghidra.util.table.GhidraProgramTableModel;
import ghidra.util.table.actions.DeleteTableRowAction;
import ghidra.util.task.SwingUpdateManager;
@@ -73,7 +74,7 @@ public class TableServicePlugin extends ProgramPlugin
// Unusual Code: We, as a plugin, don't have any actions. Our transient tables do have
// actions. We need a way to have keybindings shared for all the different
// actions. Further, we need to register them now, not when the transient
- // providers are created, as they would only appear in the options at
+ // providers are created, as they would only appear in the options at
// that point.
//
DeleteTableRowAction.registerDummy(tool, getName());
@@ -265,16 +266,13 @@ public class TableServicePlugin extends ProgramPlugin
navigatable = gotoService.getDefaultNavigatable();
}
- TableChooserDialog dialog =
- new MyTableChooserDialog(this, executor, program, title, navigatable, isModal);
+ Navigatable nav = navigatable;
+ TableChooserDialog dialog = Swing.runNow(
+ () -> new MyTableChooserDialog(this, executor, program, title, nav, isModal));
- List<TableChooserDialog> list = programToDialogMap.get(program);
- if (list == null) {
- list = new ArrayList<>();
- programToDialogMap.put(program, list);
- }
+ List<TableChooserDialog> list =
+ programToDialogMap.computeIfAbsent(program, p -> new ArrayList<>());
list.add(dialog);
return dialog;
}
-
}
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/script/GhidraScriptTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/script/GhidraScriptTest.java
index dd05284ae5..c8141cad34 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/script/GhidraScriptTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/script/GhidraScriptTest.java
@@ -52,10 +52,6 @@ public class GhidraScriptTest extends AbstractGhidraHeadedIntegrationTest {
private Program program;
private GhidraState state;
- public GhidraScriptTest() {
- super();
- }
-
@Before
public void setUp() throws Exception {
@@ -522,8 +518,10 @@ public class GhidraScriptTest extends AbstractGhidraHeadedIntegrationTest {
// Try to set a valid option to an invalid value and verify that the invalid value was not stored.
String invalidValue = "d";
script.setAnalysisOption(program, validOptionName, invalidValue);
- assertFalse(script.getCurrentAnalysisOptionsAndValues(program).get(validOptionName).equals(
- invalidValue));
+ assertFalse(script.getCurrentAnalysisOptionsAndValues(program)
+ .get(validOptionName)
+ .equals(
+ invalidValue));
// Try to set an invalid option and verify that the option is not successfully set.
String invalidOption = "invalidOption";
@@ -826,7 +824,7 @@ public class GhidraScriptTest extends AbstractGhidraHeadedIntegrationTest {
//==================================================================================================
// Inner Classes
-//==================================================================================================
+//==================================================================================================
public enum TestEnum {
a, b, c