mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
Merge remote-tracking branch 'origin/patch'
Conflicts: Ghidra/Features/ByteViewer/src/main/java/ghidra/app/plugin/core/byteviewer/ByteViewerPlugin.java
This commit is contained in:
commit
d428f30a85
2 changed files with 45 additions and 50 deletions
|
@ -455,7 +455,7 @@ public abstract class ByteViewerComponentProvider extends ComponentProviderAdapt
|
|||
* @param message non-html text to display
|
||||
*/
|
||||
void setStatusMessage(String message) {
|
||||
plugin.setStatusMessage(message, this);
|
||||
plugin.setStatusMessage(message);
|
||||
}
|
||||
|
||||
void setEditMode(boolean isEditable) {
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.*;
|
|||
import org.jdom.Element;
|
||||
|
||||
import docking.ActionContext;
|
||||
import docking.ComponentProvider;
|
||||
import docking.action.DockingAction;
|
||||
import docking.action.ToolBarData;
|
||||
import ghidra.app.CorePluginPackage;
|
||||
|
@ -37,6 +36,7 @@ import ghidra.program.util.ProgramLocation;
|
|||
import ghidra.program.util.ProgramSelection;
|
||||
import ghidra.util.SystemUtilities;
|
||||
import resources.ResourceManager;
|
||||
import utility.function.Callback;
|
||||
|
||||
/**
|
||||
* Visible Plugin to show ByteBlock data in various formats.
|
||||
|
@ -62,7 +62,7 @@ import resources.ResourceManager;
|
|||
public class ByteViewerPlugin extends Plugin {
|
||||
|
||||
private Program currentProgram;
|
||||
private boolean restoringTransientState;
|
||||
private boolean areEventsDisabled;
|
||||
private ProgramLocation currentLocation;
|
||||
|
||||
private ProgramByteViewerComponentProvider connectedProvider;
|
||||
|
@ -155,11 +155,12 @@ public class ByteViewerPlugin extends Plugin {
|
|||
|
||||
public void fireProgramLocationPluginEvent(ProgramByteViewerComponentProvider provider,
|
||||
ProgramLocationPluginEvent event) {
|
||||
|
||||
if (SystemUtilities.isEqual(event.getLocation(), currentLocation)) {
|
||||
return;
|
||||
}
|
||||
currentLocation = event.getLocation();
|
||||
|
||||
currentLocation = event.getLocation();
|
||||
if (provider == connectedProvider) {
|
||||
firePluginEvent(event);
|
||||
}
|
||||
|
@ -190,6 +191,9 @@ public class ByteViewerPlugin extends Plugin {
|
|||
*/
|
||||
@Override
|
||||
public void readDataState(SaveState saveState) {
|
||||
|
||||
doWithEventsDisabled(() -> {
|
||||
|
||||
ProgramManager programManagerService = tool.getService(ProgramManager.class);
|
||||
|
||||
connectedProvider.readDataState(saveState);
|
||||
|
@ -214,6 +218,8 @@ public class ByteViewerPlugin extends Plugin {
|
|||
addProvider(provider);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -290,8 +296,6 @@ public class ByteViewerPlugin extends Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
@Override
|
||||
public Object getTransientState() {
|
||||
Object[] state = new Object[2];
|
||||
|
@ -305,40 +309,31 @@ public class ByteViewerPlugin extends Plugin {
|
|||
return state;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see ghidra.framework.plugintool.Plugin#restoreTransientState(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public void restoreTransientState(Object objectState) {
|
||||
restoringTransientState = true;
|
||||
try {
|
||||
|
||||
doWithEventsDisabled(() -> {
|
||||
Object[] state = (Object[]) objectState;
|
||||
|
||||
connectedProvider.restoreLocation((SaveState) state[0]);
|
||||
|
||||
connectedProvider.setSelection((ProgramSelection) state[1]);
|
||||
});
|
||||
}
|
||||
|
||||
private void doWithEventsDisabled(Callback callback) {
|
||||
areEventsDisabled = true;
|
||||
try {
|
||||
callback.call();
|
||||
}
|
||||
finally {
|
||||
restoringTransientState = false;
|
||||
areEventsDisabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
// *** package-level methods ***
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
boolean isRestoringTransientState() {
|
||||
return restoringTransientState;
|
||||
private boolean eventsDisabled() {
|
||||
return areEventsDisabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the status info on the tool.
|
||||
*
|
||||
* @param msg text to display
|
||||
* @param provider not used
|
||||
*/
|
||||
void setStatusMessage(String msg, ComponentProvider provider) {
|
||||
void setStatusMessage(String msg) {
|
||||
tool.setStatusInfo(msg);
|
||||
}
|
||||
|
||||
|
@ -384,7 +379,7 @@ public class ByteViewerPlugin extends Plugin {
|
|||
public void updateLocation(ProgramByteViewerComponentProvider provider,
|
||||
ProgramLocationPluginEvent event, boolean export) {
|
||||
|
||||
if (isRestoringTransientState()) {
|
||||
if (eventsDisabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue