GP-5346 - Decompiler - Fixed sporadic function color bug that caused bad

function colors to oscillate
This commit is contained in:
dragonmacher 2025-03-04 18:06:51 -05:00
parent 802586c6fb
commit f078e5fe62
3 changed files with 20 additions and 13 deletions

View file

@ -53,7 +53,6 @@ public class AttributedStringPcodeFormatter extends
* Constructor * Constructor
*/ */
public AttributedStringPcodeFormatter() { public AttributedStringPcodeFormatter() {
initPunctuation();
} }
/** /**

View file

@ -206,13 +206,20 @@ public class ClangLayoutController implements LayoutModel, LayoutModelListener {
if (token instanceof ClangFuncNameToken clangFunctionToken) { if (token instanceof ClangFuncNameToken clangFunctionToken) {
Program program = decompilerPanel.getProgram(); Program program = decompilerPanel.getProgram();
Function function = DecompilerUtils.getFunction(program, clangFunctionToken); Function function = DecompilerUtils.getFunction(program, clangFunctionToken);
if (function == null || function instanceof UndefinedFunction) { if (isValidFunction(function)) {
return null; Symbol symbol = function.getSymbol();
tokenColor = symbolInspector.getColor(symbol);
} }
Symbol symbol = function.getSymbol();
return symbolInspector.getColor(symbol);
} }
return tokenColor;
if (tokenColor != null) {
return tokenColor;
}
return syntaxColor[ClangToken.ERROR_COLOR];
}
private boolean isValidFunction(Function f) {
return f != null && !(f instanceof UndefinedFunction);
} }
/** /**

View file

@ -16,6 +16,7 @@
package docking.widgets.fieldpanel.field; package docking.widgets.fieldpanel.field;
import java.awt.*; import java.awt.*;
import java.util.Objects;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JComponent; import javax.swing.JComponent;
@ -94,9 +95,9 @@ public class AttributedString {
throw new NullPointerException("underline color cannot be null when underlining."); throw new NullPointerException("underline color cannot be null when underlining.");
} }
this.icon = icon; this.icon = icon;
this.text = text; this.text = Objects.requireNonNull(text);
this.fontMetrics = fontMetrics; this.fontMetrics = Objects.requireNonNull(fontMetrics);
this.textColor = textColor; this.textColor = Objects.requireNonNull(textColor);
this.isUnderlined = underline; this.isUnderlined = underline;
this.underlineColor = underlineColor; this.underlineColor = underlineColor;
} }