mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
GP-1334 - Fixed exception due to the Patch action being incorrectly
added to the Function Graph context menu Closes #3288
This commit is contained in:
parent
156ce7ef80
commit
a36f17c782
1 changed files with 29 additions and 27 deletions
|
@ -67,7 +67,7 @@ public class AssembleDockingAction extends DockingAction {
|
||||||
private FieldPanel codepane;
|
private FieldPanel codepane;
|
||||||
private ListingPanel listpane;
|
private ListingPanel listpane;
|
||||||
private Map<Language, CachingSwingWorker<Assembler>> cache =
|
private Map<Language, CachingSwingWorker<Assembler>> cache =
|
||||||
LazyMap.lazyMap(new HashMap<>(), (Language lang) -> new AssemblerConstructorWorker(lang));
|
LazyMap.lazyMap(new HashMap<>(), language -> new AssemblerConstructorWorker(language));
|
||||||
|
|
||||||
private Map<Language, Boolean> shownWarning = DefaultedMap.defaultedMap(new HashMap<>(), false);
|
private Map<Language, Boolean> shownWarning = DefaultedMap.defaultedMap(new HashMap<>(), false);
|
||||||
|
|
||||||
|
@ -153,9 +153,6 @@ public class AssembleDockingAction extends DockingAction {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Create the action, allocating its resources and settings its default menu and key data
|
|
||||||
*/
|
|
||||||
public AssembleDockingAction(PluginTool tool, String name, String owner) {
|
public AssembleDockingAction(PluginTool tool, String name, String owner) {
|
||||||
this(name, owner);
|
this(name, owner);
|
||||||
//this.tool = tool;
|
//this.tool = tool;
|
||||||
|
@ -189,12 +186,16 @@ public class AssembleDockingAction extends DockingAction {
|
||||||
|
|
||||||
protected void prepareLayout(ActionContext context) {
|
protected void prepareLayout(ActionContext context) {
|
||||||
ComponentProvider prov = context.getComponentProvider();
|
ComponentProvider prov = context.getComponentProvider();
|
||||||
if (cv != prov) {
|
if (cv == prov) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (cv != null) {
|
if (cv != null) {
|
||||||
codepane.setLayout(null);
|
codepane.setLayout(null);
|
||||||
fieldLayoutManager.removeLayoutListener(autoCompleteMover);
|
fieldLayoutManager.removeLayoutListener(autoCompleteMover);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// we are only added to the popup for a ListingActionContext that has a CodeViewerProvider
|
||||||
cv = (CodeViewerProvider) prov;
|
cv = (CodeViewerProvider) prov;
|
||||||
listpane = cv.getListingPanel();
|
listpane = cv.getListingPanel();
|
||||||
codepane = listpane.getFieldPanel();
|
codepane = listpane.getFieldPanel();
|
||||||
|
@ -203,7 +204,6 @@ public class AssembleDockingAction extends DockingAction {
|
||||||
codepane.setLayout(fieldLayoutManager);
|
codepane.setLayout(fieldLayoutManager);
|
||||||
fieldLayoutManager.addLayoutListener(autoCompleteMover);
|
fieldLayoutManager.addLayoutListener(autoCompleteMover);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cancel the current assembly action
|
* Cancel the current assembly action
|
||||||
|
@ -227,14 +227,14 @@ public class AssembleDockingAction extends DockingAction {
|
||||||
* Retrieve the location in the code viewer's {@link FieldPanel} for the field at the given
|
* Retrieve the location in the code viewer's {@link FieldPanel} for the field at the given
|
||||||
* address having the given header text
|
* address having the given header text
|
||||||
*
|
*
|
||||||
* @param addr the address
|
* @param address the address
|
||||||
* @param fieldName the name of the field
|
* @param fieldName the name of the field
|
||||||
* @return if found, the {@link FieldLocation}, otherwise {@code null}
|
* @return if found, the {@link FieldLocation}, otherwise {@code null}
|
||||||
*/
|
*/
|
||||||
protected FieldLocation findFieldLocation(Address addr, String fieldName) {
|
protected FieldLocation findFieldLocation(Address address, String fieldName) {
|
||||||
Layout layout = listpane.getLayout(addr);
|
Layout layout = listpane.getLayout(address);
|
||||||
ListingModelAdapter adapter = (ListingModelAdapter) codepane.getLayoutModel();
|
ListingModelAdapter adapter = (ListingModelAdapter) codepane.getLayoutModel();
|
||||||
BigInteger index = adapter.getAddressIndexMap().getIndex(addr);
|
BigInteger index = adapter.getAddressIndexMap().getIndex(address);
|
||||||
int count = layout.getNumFields();
|
int count = layout.getNumFields();
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
ListingField field = (ListingField) layout.getField(i);
|
ListingField field = (ListingField) layout.getField(i);
|
||||||
|
@ -368,18 +368,20 @@ public class AssembleDockingAction extends DockingAction {
|
||||||
@Override
|
@Override
|
||||||
public boolean isAddToPopup(ActionContext context) {
|
public boolean isAddToPopup(ActionContext context) {
|
||||||
|
|
||||||
// currently only works on a listing
|
// currently only works on a listing that has a CodeViewerProvider
|
||||||
if (!(context instanceof ListingActionContext)) {
|
if (!(context instanceof ListingActionContext)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ListingActionContext lac = (ListingActionContext) context;
|
ListingActionContext lac = (ListingActionContext) context;
|
||||||
ComponentProvider cp = lac.getComponentProvider();
|
ComponentProvider cp = lac.getComponentProvider();
|
||||||
if (cp instanceof CodeViewerProvider) {
|
if (!(cp instanceof CodeViewerProvider)) {
|
||||||
CodeViewerProvider cv = (CodeViewerProvider) cp;
|
|
||||||
if (cv.isReadOnly()) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CodeViewerProvider codeViewer = (CodeViewerProvider) cp;
|
||||||
|
if (codeViewer.isReadOnly()) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Program program = lac.getProgram();
|
Program program = lac.getProgram();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue