mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
Merge remote-tracking branch
'origin/GT-3470-dragonmacher-decompiler-highlight-bug' Fixes #1445
This commit is contained in:
commit
cb0f8fee7a
2 changed files with 22 additions and 3 deletions
|
@ -66,6 +66,11 @@ public abstract class ClangHighlightController {
|
|||
private TokenHighlights secondaryHighlightTokens = new TokenHighlights();
|
||||
private TokenHighlightColors secondaryHighlightColors = new TokenHighlightColors();
|
||||
|
||||
/**
|
||||
* A counter to track updates so that clients know when a buffered highlight request is invalid
|
||||
*/
|
||||
private long updateId;
|
||||
|
||||
private List<ClangHighlightListener> listeners = new ArrayList<>();
|
||||
|
||||
public abstract void fieldLocationChanged(FieldLocation location, Field field,
|
||||
|
@ -83,6 +88,10 @@ public abstract class ClangHighlightController {
|
|||
return null;
|
||||
}
|
||||
|
||||
public long getUpdateId() {
|
||||
return updateId;
|
||||
}
|
||||
|
||||
public TokenHighlightColors getSecondaryHighlightColors() {
|
||||
return secondaryHighlightColors;
|
||||
}
|
||||
|
@ -133,7 +142,6 @@ public abstract class ClangHighlightController {
|
|||
}
|
||||
|
||||
private void doClearHighlights(TokenHighlights tokenHighlights) {
|
||||
|
||||
Iterator<HighlightToken> it = tokenHighlights.iterator();
|
||||
while (it.hasNext()) {
|
||||
HighlightToken highlight = it.next();
|
||||
|
@ -243,6 +251,9 @@ public abstract class ClangHighlightController {
|
|||
|
||||
private void addTokensToHighlights(Collection<ClangToken> tokens,
|
||||
Function<ClangToken, Color> colorProvider, TokenHighlights currentHighlights) {
|
||||
|
||||
updateId++;
|
||||
|
||||
for (ClangToken clangToken : tokens) {
|
||||
Color color = colorProvider.apply(clangToken);
|
||||
doAddHighlight(clangToken, color, currentHighlights);
|
||||
|
|
|
@ -199,7 +199,6 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
|
|||
}
|
||||
|
||||
private void togglePrimaryHighlight(FieldLocation location, Field field, Color highlightColor) {
|
||||
|
||||
ClangToken token = ((ClangTextField) field).getToken(location);
|
||||
Supplier<List<ClangToken>> lazyTokens = () -> findTokensByName(token.getText());
|
||||
highlightController.togglePrimaryHighlights(middleMouseHighlightColor, lazyTokens);
|
||||
|
@ -1151,15 +1150,24 @@ public class DecompilerPanel extends JPanel implements FieldMouseListener, Field
|
|||
private FieldLocation location;
|
||||
private Field field;
|
||||
private EventTrigger trigger;
|
||||
private long updateId;
|
||||
|
||||
PendingHighlightUpdate(FieldLocation location, Field field, EventTrigger trigger) {
|
||||
this.location = location;
|
||||
this.field = field;
|
||||
this.trigger = trigger;
|
||||
this.updateId = highlightController.getUpdateId();
|
||||
}
|
||||
|
||||
void doUpdate() {
|
||||
highlightController.fieldLocationChanged(location, field, trigger);
|
||||
|
||||
// Note: don't send this buffered cursor change highlight if some other highlight
|
||||
// has been applied. Otherwise, this highlight would overwrite the last
|
||||
// applied highlight.
|
||||
long lastUpdateId = highlightController.getUpdateId();
|
||||
if (updateId == lastUpdateId) {
|
||||
highlightController.fieldLocationChanged(location, field, trigger);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue