Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-0 Corrected test issues

ghidra11a80aff30a56
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorModel.java
index d55a0914e0..0ef73765f2 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorModel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorModel.java
@@ -692,7 +692,7 @@ abstract public class CompositeEditorModel extends CompositeViewerModel {
if (!isArrayAllowed()) {
throw new UsrException("Array not permitted in current context");
}
- int min = 0;
+ int min = allowsZeroLengthComponents() ? 0 : 1;
int max = getMaxElements();
if (isSingleRowSelection()) {
if (max != 0) {
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/StructureEditorModel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/StructureEditorModel.java
index 7ae58ee855..a75b222ccf 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/StructureEditorModel.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/StructureEditorModel.java
@@ -20,6 +20,8 @@ import java.util.*;
import javax.swing.table.TableColumn;
+import org.apache.commons.lang3.StringUtils;
+
import docking.widgets.OptionDialog;
import docking.widgets.dialogs.InputDialog;
import docking.widgets.dialogs.InputDialogListener;
@@ -1458,7 +1460,7 @@ class StructureEditorModel extends CompEditorModel {
selection.addRange(rowIndex, rowIndex + numComps);
DataTypeComponent comp = getComponent(rowIndex);
- // Set the field name and comment the same as before
+ // Set the field name and comment the same as before if unspecified
try {
if (comp.getFieldName() == null) {
comp.setFieldName(fieldName);
@@ -1467,7 +1469,9 @@ class StructureEditorModel extends CompEditorModel {
catch (DuplicateNameException exc) {
Msg.showError(this, null, null, null);
}
- comp.setComment(comment);
+ if (StringUtils.isBlank(comp.getComment())) {
+ comp.setComment(comment);
+ }
});
fixSelection();
componentEdited();
@@ -1488,6 +1492,5 @@ class StructureEditorModel extends CompEditorModel {
zeroDtc.getFieldName(), zeroDtc.getComment());
}
}
- zeroDtcStack.clear();
}
}
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedEnablementTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedEnablementTest.java
index 504e8f085f..a5c824d641 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedEnablementTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedEnablementTest.java
@@ -361,7 +361,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor
setSelection(new int[] { 19 });
assertEquals("simpleStructureTypedef", getDataType(19).getDisplayName());
- assertTrue(!unpackageAction.isEnabled());
+ assertTrue(unpackageAction.isEnabled());
setSelection(new int[] { 21 });
assertEquals("simpleStructure", getDataType(21).getDisplayName());
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedEnablementTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedEnablementTest.java
index d3604b207b..34a7932f6c 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedEnablementTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedEnablementTest.java
@@ -341,7 +341,7 @@ public class StructureEditorUnlockedEnablementTest extends AbstractStructureEdit
setSelection(new int[] { 19 });
assertEquals("simpleStructureTypedef", getDataType(19).getDisplayName());
- assertTrue(!unpackageAction.isEnabled());
+ assertTrue(unpackageAction.isEnabled());
setSelection(new int[] { 21 });
assertEquals("simpleStructure", getDataType(21).getDisplayName());