From c999cfc308685b60fb8332b66bdd7eaf47f4daef Mon Sep 17 00:00:00 2001 From: tom Date: Tue, 19 May 2020 07:40:01 -0400 Subject: [PATCH] Change reuse/append display to choose a display that is currently visible. This will be the one in the open tab. --- .../DefaultGraphDisplayProvider.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) 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