mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 12:00:04 +02:00
fixing duplicate graph actions when re-using a graph. Also fixed problem with actions being added on non-swing thread.
This commit is contained in:
parent
55e562650f
commit
66d052ce24
4 changed files with 42 additions and 6 deletions
|
@ -1216,7 +1216,7 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addAction(DockingAction action) {
|
public void addAction(DockingAction action) {
|
||||||
componentProvider.addLocalAction(action);
|
Swing.runLater(() -> componentProvider.addLocalAction(action));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1286,4 +1286,19 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
||||||
public AttributedGraph getGraph() {
|
public AttributedGraph getGraph() {
|
||||||
return graph;
|
return graph;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all externally added actions. This is called before re-using the graph window for a
|
||||||
|
* new graph which may add its own set of actions for that particular graph.
|
||||||
|
*/
|
||||||
|
void restoreToDefaultSetOfActions() {
|
||||||
|
Swing.runLater(() -> {
|
||||||
|
// remove all actions
|
||||||
|
componentProvider.removeAllLocalActions();
|
||||||
|
// put the standard graph actions back
|
||||||
|
createToolbarActions();
|
||||||
|
createPopupActions();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,4 +69,10 @@ public class DefaultGraphDisplayComponentProvider extends ComponentProviderAdapt
|
||||||
public ActionContext getActionContext(MouseEvent event) {
|
public ActionContext getActionContext(MouseEvent event) {
|
||||||
return display.getActionContext(event);
|
return display.getActionContext(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// overridden to make it accessible
|
||||||
|
@Override
|
||||||
|
public void removeAllLocalActions() {
|
||||||
|
super.removeAllLocalActions();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,9 @@ public class DefaultGraphDisplayProvider implements GraphDisplayProvider {
|
||||||
TaskMonitor monitor) {
|
TaskMonitor monitor) {
|
||||||
|
|
||||||
if (reuseGraph && !displays.isEmpty()) {
|
if (reuseGraph && !displays.isEmpty()) {
|
||||||
return getVisibleGraph();
|
DefaultGraphDisplay visibleGraph = getVisibleGraph();
|
||||||
|
visibleGraph.restoreToDefaultSetOfActions();
|
||||||
|
return visibleGraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultGraphDisplay display =
|
DefaultGraphDisplay display =
|
||||||
|
@ -73,9 +75,11 @@ public class DefaultGraphDisplayProvider implements GraphDisplayProvider {
|
||||||
* return one from the Set via its iterator
|
* return one from the Set via its iterator
|
||||||
* @return a display that is showing
|
* @return a display that is showing
|
||||||
*/
|
*/
|
||||||
private GraphDisplay getVisibleGraph() {
|
private DefaultGraphDisplay getVisibleGraph() {
|
||||||
return displays.stream().filter(d -> d.getComponent().isShowing())
|
return displays.stream()
|
||||||
.findAny().orElse(displays.iterator().next());
|
.filter(d -> d.getComponent().isShowing())
|
||||||
|
.findAny()
|
||||||
|
.orElse(displays.iterator().next());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -100,4 +104,5 @@ public class DefaultGraphDisplayProvider implements GraphDisplayProvider {
|
||||||
public void remove(DefaultGraphDisplay defaultGraphDisplay) {
|
public void remove(DefaultGraphDisplay defaultGraphDisplay) {
|
||||||
displays.remove(defaultGraphDisplay);
|
displays.remove(defaultGraphDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,7 +267,7 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the given action from the system.
|
* Removes the given action from this component provider.
|
||||||
* @param action The action to remove.
|
* @param action The action to remove.
|
||||||
*/
|
*/
|
||||||
protected void removeLocalAction(DockingAction action) {
|
protected void removeLocalAction(DockingAction action) {
|
||||||
|
@ -277,6 +277,16 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all local actions from this component provider
|
||||||
|
*/
|
||||||
|
protected void removeAllLocalActions() {
|
||||||
|
if (isInTool()) {
|
||||||
|
actionSet.forEach(action -> dockingTool.removeLocalAction(this, action));
|
||||||
|
}
|
||||||
|
actionSet.clear();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience method to show or hide this provider.
|
* Convenience method to show or hide this provider.
|
||||||
* @param visible True shows the provider; false hides the provider
|
* @param visible True shows the provider; false hides the provider
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue