Skip to content

Ghidra is a software reverse engineering (SRE) framework

Change reuse/append display to choose a display that is currently visible. This will be the one in the open tab.

tomc999cfc30868
diff --git a/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/visualization/DefaultGraphDisplayProvider.java b/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/visualization/DefaultGraphDisplayProvider.java
index 403816344d..bc7e3262e2 100644
--- a/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/visualization/DefaultGraphDisplayProvider.java
+++ b/Ghidra/Features/GraphServices/src/main/java/ghidra/graph/visualization/DefaultGraphDisplayProvider.java
@@ -51,7 +51,7 @@ public class DefaultGraphDisplayProvider implements GraphDisplayProvider {
TaskMonitor monitor) {
if (reuseGraph && !displays.isEmpty()) {
- return getExistingGraph();
+ return getVisibleGraph();
}
DefaultGraphDisplay display =
@@ -66,9 +66,16 @@ public class DefaultGraphDisplayProvider implements GraphDisplayProvider {
this.options = graphOptions;
}
- private GraphDisplay getExistingGraph() {
- DefaultGraphDisplay display = displays.iterator().next();
- return display;
+ /**
+ * Get a {@code GraphDisplay} that is 'showing', assuming that is the one the user
+ * wishes to append to.
+ * Called only when displays is not empty. If there are no 'showing' displays,
+ * 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());
}
@Override