mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +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
|
||||
public void addAction(DockingAction action) {
|
||||
componentProvider.addLocalAction(action);
|
||||
Swing.runLater(() -> componentProvider.addLocalAction(action));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1286,4 +1286,19 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
|||
public AttributedGraph getGraph() {
|
||||
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) {
|
||||
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) {
|
||||
|
||||
if (reuseGraph && !displays.isEmpty()) {
|
||||
return getVisibleGraph();
|
||||
DefaultGraphDisplay visibleGraph = getVisibleGraph();
|
||||
visibleGraph.restoreToDefaultSetOfActions();
|
||||
return visibleGraph;
|
||||
}
|
||||
|
||||
DefaultGraphDisplay display =
|
||||
|
@ -73,9 +75,11 @@ public class DefaultGraphDisplayProvider implements GraphDisplayProvider {
|
|||
* return one from the Set via its iterator
|
||||
* @return a display that is showing
|
||||
*/
|
||||
private GraphDisplay getVisibleGraph() {
|
||||
return displays.stream().filter(d -> d.getComponent().isShowing())
|
||||
.findAny().orElse(displays.iterator().next());
|
||||
private DefaultGraphDisplay getVisibleGraph() {
|
||||
return displays.stream()
|
||||
.filter(d -> d.getComponent().isShowing())
|
||||
.findAny()
|
||||
.orElse(displays.iterator().next());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -100,4 +104,5 @@ public class DefaultGraphDisplayProvider implements GraphDisplayProvider {
|
|||
public void remove(DefaultGraphDisplay defaultGraphDisplay) {
|
||||
displays.remove(defaultGraphDisplay);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue