Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-1333 - Fixed memory search dialog issue caused by odd resizing when using the Advanced button

dragonmacher6243133e1dc2
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchDialog.java
index 63499df423..bbe4ee6b37 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchDialog.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchmem/MemSearchDialog.java
@@ -59,6 +59,13 @@ class MemSearchDialog extends DialogComponentProvider {
private static final SearchData DEFAULT_SEARCH_DATA =
SearchData.createInvalidInputSearchData(ENTER_TEXT_MESSAGE);
+ // The fields that use this value take in user input. If the user input large, it affects
+ // the minimum and preferred size of the the fields. This, in turn, affects how this dialog
+ // gets packed when the Advanced button is toggled. Without using a size restriction, this
+ // dialog's contents may move as the dialog is re-packed.
+ private static final int INPUT_FIELD_MIN_SIZE_WIDTH = 140;
+ private static final int INPUT_FIELD_MIN_SIZE_HEIGHT = 25;
+
MemSearchPlugin plugin;
boolean isMnemonic;
@@ -300,10 +307,9 @@ class MemSearchDialog extends DialogComponentProvider {
inputPanel.setLayout(new GridLayout(0, 1));
valueComboBox = new GhidraComboBox<>();
valueComboBox.setEditable(true);
- valueField = (JTextField) valueComboBox.getEditor().getEditorComponent();
+ valueField = (JTextField) valueComboBox.getEditor().getEditorComponent();
valueField.setToolTipText(currentFormat.getToolTip());
-
valueField.setDocument(new RestrictedInputDocument());
valueField.addActionListener(ev -> {
if (nextButton.isEnabled()) {
@@ -315,6 +321,15 @@ class MemSearchDialog extends DialogComponentProvider {
hexSeqField = new GDLabel();
hexSeqField.setName("HexSequenceField");
hexSeqField.setBorder(BorderFactory.createLoweredBevelBorder());
+
+ // see note for field minimum size field above
+ Dimension size = new Dimension(INPUT_FIELD_MIN_SIZE_WIDTH, INPUT_FIELD_MIN_SIZE_HEIGHT);
+ valueComboBox.setPreferredSize(size);
+ valueComboBox.setMinimumSize(size);
+
+ hexSeqField.setPreferredSize(size);
+ hexSeqField.setMinimumSize(size);
+
inputPanel.add(hexSeqField);
JPanel searchPanel = new JPanel(new BorderLayout());