mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-06 03:50:02 +02:00
Fixed tests broken due to the flush() call buffering and not executing
immediately
This commit is contained in:
parent
422d41dd53
commit
e4fac450f0
2 changed files with 25 additions and 32 deletions
|
@ -18,7 +18,7 @@ package ghidra.util.task;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
|
|
||||||
import ghidra.util.Msg;
|
import ghidra.util.Msg;
|
||||||
import ghidra.util.SystemUtilities;
|
import ghidra.util.Swing;
|
||||||
import ghidra.util.datastruct.WeakDataStructureFactory;
|
import ghidra.util.datastruct.WeakDataStructureFactory;
|
||||||
import ghidra.util.datastruct.WeakSet;
|
import ghidra.util.datastruct.WeakSet;
|
||||||
import utilities.util.reflection.ReflectionUtilities;
|
import utilities.util.reflection.ReflectionUtilities;
|
||||||
|
@ -67,9 +67,9 @@ public abstract class AbstractSwingUpdateManager {
|
||||||
private final String name;
|
private final String name;
|
||||||
private String inceptionInformation;
|
private String inceptionInformation;
|
||||||
|
|
||||||
protected long requestTime = NONE;
|
private long requestTime = NONE;
|
||||||
protected long bufferingStartTime;
|
private long bufferingStartTime;
|
||||||
protected boolean disposed = false;
|
private boolean disposed = false;
|
||||||
|
|
||||||
// This is true when work has begun and is not finished. This is only mutated on the
|
// 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.
|
// Swing thread, but is read by other threads.
|
||||||
|
@ -148,7 +148,7 @@ public abstract class AbstractSwingUpdateManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
requestTime = System.currentTimeMillis();
|
requestTime = System.currentTimeMillis();
|
||||||
SystemUtilities.runSwingLater(this::checkForWork);
|
Swing.runLater(this::checkForWork);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -175,19 +175,33 @@ public abstract class AbstractSwingUpdateManager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// force an update by disabling buffering with a new request
|
||||||
requestTime = System.currentTimeMillis();
|
requestTime = System.currentTimeMillis();
|
||||||
bufferingStartTime = NONE; // set so that the max delay check will trigger work
|
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
|
* Causes this run manager to run if it has a pending update
|
||||||
*/
|
*/
|
||||||
public void flush() {
|
public void flush() {
|
||||||
if (hasPendingUpdates()) {
|
synchronized (this) {
|
||||||
SystemUtilities.runSwingNow(this::checkForWork);
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,8 +15,6 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.util.task;
|
package ghidra.util.task;
|
||||||
|
|
||||||
import ghidra.util.Swing;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class to allow clients to buffer events. UI components may receive numbers events to make
|
* 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
|
* changes to their underlying data model. Further, for many of these clients, it is sufficient
|
||||||
|
@ -116,12 +114,7 @@ public class SwingUpdateManager extends AbstractSwingUpdateManager {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized void update() {
|
public synchronized void update() {
|
||||||
if (disposed) {
|
super.update();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
requestTime = System.currentTimeMillis();
|
|
||||||
Swing.runLater(this::checkForWork);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,13 +123,7 @@ public class SwingUpdateManager extends AbstractSwingUpdateManager {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public synchronized void updateLater() {
|
public synchronized void updateLater() {
|
||||||
if (disposed) {
|
super.updateLater();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
requestTime = System.currentTimeMillis();
|
|
||||||
bufferingStartTime = bufferingStartTime == NONE ? requestTime : bufferingStartTime;
|
|
||||||
scheduleCheckForWork();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -145,15 +132,7 @@ public class SwingUpdateManager extends AbstractSwingUpdateManager {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void updateNow() {
|
public void updateNow() {
|
||||||
synchronized (this) {
|
super.updateNow();
|
||||||
if (disposed) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
requestTime = System.currentTimeMillis();
|
|
||||||
bufferingStartTime = NONE; // set so that the max delay check will trigger work
|
|
||||||
}
|
|
||||||
Swing.runLater(this::checkForWork);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue