mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-01-09 22:17:55 -05:00
GP-5881 Corrected regression error with Structure editor change
This commit is contained in:
@@ -55,6 +55,18 @@ public abstract class CompEditorModel<T extends Composite> extends CompositeEdit
|
||||
*/
|
||||
@Override
|
||||
public void load(T dataType) {
|
||||
|
||||
if (dataType.isDeleted()) {
|
||||
// This can occur when mayny events get lumped together and a change event triggers
|
||||
// a delayed reload prior to datatype removal and its event
|
||||
if (dataType == originalComposite) {
|
||||
// Re-route to dataTypeRemoved callback after restoring listener.
|
||||
originalDTM.addDataTypeManagerListener(this);
|
||||
dataTypeRemoved(originalDTM, originalDataTypePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
super.load(dataType);
|
||||
fixSelection();
|
||||
selectionChanged();
|
||||
@@ -1363,6 +1375,8 @@ public abstract class CompEditorModel<T extends Composite> extends CompositeEdit
|
||||
}
|
||||
|
||||
reloadFromView();
|
||||
|
||||
setStatus("The original " + getTypeName() + " has been deleted");
|
||||
}
|
||||
finally {
|
||||
consideringReplacedDataType = false;
|
||||
|
||||
@@ -140,6 +140,17 @@ abstract public class CompositeEditorModel<T extends Composite> extends Composit
|
||||
"Datatype " + dataType.getName() + " doesn't have a data type manager specified.");
|
||||
}
|
||||
|
||||
if (dataType.isDeleted()) {
|
||||
// This can occur when mayny events get lumped together and a change event triggers
|
||||
// a delayed reload prior to datatype removal and its event
|
||||
if (dataType == originalComposite) {
|
||||
// Re-route to dataTypeRemoved callback after restoring listener.
|
||||
originalDTM.addDataTypeManagerListener(this);
|
||||
dataTypeRemoved(originalDTM, originalDataTypePath);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
long lastCompositeId = originalCompositeId;
|
||||
|
||||
if (isEditingField()) {
|
||||
|
||||
@@ -38,6 +38,10 @@ public class StructureEditorProvider
|
||||
public StructureEditorProvider(Plugin plugin, Structure structureDataType,
|
||||
boolean showHexNumbers) {
|
||||
super(plugin);
|
||||
if (structureDataType.isDeleted()) {
|
||||
throw new IllegalArgumentException(
|
||||
"Structure has been deleted: " + structureDataType.getPathName());
|
||||
}
|
||||
setIcon(STRUCTURE_EDITOR_ICON);
|
||||
editorModel = new StructureEditorModel(this, showHexNumbers);
|
||||
editorModel.load(structureDataType);
|
||||
|
||||
@@ -31,6 +31,10 @@ public class UnionEditorProvider extends CompositeEditorProvider<Union, UnionEdi
|
||||
|
||||
public UnionEditorProvider(Plugin plugin, Union unionDataType, boolean showInHex) {
|
||||
super(plugin);
|
||||
if (unionDataType.isDeleted()) {
|
||||
throw new IllegalArgumentException(
|
||||
"Union has been deleted: " + unionDataType.getPathName());
|
||||
}
|
||||
setIcon(UNION_EDITOR_ICON);
|
||||
editorModel = new UnionEditorModel(this, showInHex);
|
||||
editorModel.load(unionDataType);
|
||||
|
||||
@@ -94,14 +94,12 @@ public class StructureEditorNotifiedTest extends AbstractStructureEditorTest {
|
||||
|
||||
DialogComponentProvider dlg = waitForDialogComponent("Close Structure Editor?");
|
||||
pressButton(dlg.getComponent(), "No");
|
||||
|
||||
waitForSwing();
|
||||
|
||||
// complexStructure* gets removed and becomes BadDataType in this editor.
|
||||
assertEquals(num, model.getNumComponents());
|
||||
assertEquals(len, model.getLength());
|
||||
assertTrue(BadDataType.dataType.isEquivalent(getDataType(10)));
|
||||
assertEquals("Type 'complexStructure *' was deleted", getComment(10));
|
||||
assertEquals("The original Structure has been deleted", model.getStatus());
|
||||
assertEquals(4, getLength(10));
|
||||
}
|
||||
|
||||
@@ -421,6 +419,7 @@ public class StructureEditorNotifiedTest extends AbstractStructureEditorTest {
|
||||
pressButtonByText(dialog, "Yes");
|
||||
dialog.dispose();
|
||||
dialog = null;
|
||||
waitForSwing();
|
||||
|
||||
assertEquals(((Structure) origCopy).getNumComponents(), model.getNumComponents());
|
||||
assertTrue(origCopy.isEquivalent(model.viewComposite));
|
||||
@@ -446,6 +445,7 @@ public class StructureEditorNotifiedTest extends AbstractStructureEditorTest {
|
||||
pressButtonByText(dialog, "No");
|
||||
dialog.dispose();
|
||||
dialog = null;
|
||||
waitForSwing();
|
||||
|
||||
assertEquals(((Structure) viewCopy).getNumComponents(), model.getNumComponents());
|
||||
assertTrue(viewCopy.isEquivalent(model.viewComposite));
|
||||
|
||||
@@ -250,6 +250,7 @@ public class UnionEditorNotifiedTest extends AbstractUnionEditorTest {
|
||||
pressButtonByText(dialog, "No");
|
||||
dialog.dispose();
|
||||
dialog = null;
|
||||
waitForSwing();
|
||||
|
||||
assertEquals(((Union) viewCopy).getNumComponents(), model.getNumComponents());
|
||||
assertTrue(viewCopy.isEquivalent(model.viewComposite));
|
||||
|
||||
Reference in New Issue
Block a user