Ghidra is a software reverse engineering (SRE) framework
Fixed tests broken due to the flush() call buffering and not executing immediately
dragonmachere4fac450f018
diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/util/task/AbstractSwingUpdateManager.java b/Ghidra/Framework/Generic/src/main/java/ghidra/util/task/AbstractSwingUpdateManager.javaindex 89ce77ffde..e1346873bd 100644--- a/Ghidra/Framework/Generic/src/main/java/ghidra/util/task/AbstractSwingUpdateManager.java+++ b/Ghidra/Framework/Generic/src/main/java/ghidra/util/task/AbstractSwingUpdateManager.java@@ -18,7 +18,7 @@ package ghidra.util.task;import javax.swing.Timer;import ghidra.util.Msg;-import ghidra.util.SystemUtilities;+import ghidra.util.Swing;import ghidra.util.datastruct.WeakDataStructureFactory;import ghidra.util.datastruct.WeakSet;import utilities.util.reflection.ReflectionUtilities;@@ -67,9 +67,9 @@ public abstract class AbstractSwingUpdateManager {private final String name;private String inceptionInformation;- protected long requestTime = NONE;- protected long bufferingStartTime;- protected boolean disposed = false;+ private long requestTime = NONE;+ private long bufferingStartTime;+ private boolean disposed = false;// This is true when work has begun and is not finished. This is only mutated on the// Swing thread, but is read by other threads.@@ -148,7 +148,7 @@ public abstract class AbstractSwingUpdateManager {}requestTime = System.currentTimeMillis();- SystemUtilities.runSwingLater(this::checkForWork);+ Swing.runLater(this::checkForWork);}/**@@ -175,19 +175,33 @@ public abstract class AbstractSwingUpdateManager {return;}+ // force an update by disabling buffering with a new requestrequestTime = System.currentTimeMillis();bufferingStartTime = NONE; // set so that the max delay check will trigger work}- SystemUtilities.runSwingNow(this::checkForWork);++ Swing.runNow(this::checkForWork);}/*** Causes this run manager to run if it has a pending update*/public void flush() {- if (hasPendingUpdates()) {- SystemUtilities.runSwingNow(this::checkForWork);+ synchronized (this) {+ if (disposed) {+ return;+ }++ if (!hasPendingUpdates()) {+ return;+ }++ // force an update by disabling buffering with a new request+ requestTime = System.currentTimeMillis();+ bufferingStartTime = NONE; // set so that the max delay check will trigger work}++ Swing.runNow(this::checkForWork);}/**diff --git a/Ghidra/Framework/Generic/src/main/java/ghidra/util/task/SwingUpdateManager.java b/Ghidra/Framework/Generic/src/main/java/ghidra/util/task/SwingUpdateManager.javaindex 9615241bde..5b4293e5ec 100644--- a/Ghidra/Framework/Generic/src/main/java/ghidra/util/task/SwingUpdateManager.java+++ b/Ghidra/Framework/Generic/src/main/java/ghidra/util/task/SwingUpdateManager.java@@ -15,8 +15,6 @@*/package ghidra.util.task;-import ghidra.util.Swing;-/*** A class to allow clients to buffer events. UI components may receive numbers events to make* changes to their underlying data model. Further, for many of these clients, it is sufficient@@ -116,12 +114,7 @@ public class SwingUpdateManager extends AbstractSwingUpdateManager {*/@Overridepublic synchronized void update() {- if (disposed) {- return;- }-- requestTime = System.currentTimeMillis();- Swing.runLater(this::checkForWork);+ super.update();}/**@@ -130,13 +123,7 @@ public class SwingUpdateManager extends AbstractSwingUpdateManager {*/@Overridepublic synchronized void updateLater() {- if (disposed) {- return;- }-- requestTime = System.currentTimeMillis();- bufferingStartTime = bufferingStartTime == NONE ? requestTime : bufferingStartTime;- scheduleCheckForWork();+ super.updateLater();}/**@@ -145,15 +132,7 @@ public class SwingUpdateManager extends AbstractSwingUpdateManager {*/@Overridepublic void updateNow() {- synchronized (this) {- if (disposed) {- return;- }-- requestTime = System.currentTimeMillis();- bufferingStartTime = NONE; // set so that the max delay check will trigger work- }- Swing.runLater(this::checkForWork);+ super.updateNow();}}