mirror of
https://github.com/skylot/jadx.git
synced 2024-11-27 14:40:54 +00:00
fix(gui): resolve various minor issues
This commit is contained in:
parent
4679172d4f
commit
8486891728
@ -145,11 +145,12 @@ public class BackgroundExecutor {
|
||||
task.onDone(this);
|
||||
// treat UI task operations as part of the task to not mix with others
|
||||
UiUtils.uiRunAndWait(() -> {
|
||||
progressPane.setVisible(false);
|
||||
task.onFinish(this);
|
||||
progressPane.setVisible(false);
|
||||
});
|
||||
} finally {
|
||||
taskComplete(id);
|
||||
progressPane.changeVisibility(this, false);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
@ -230,13 +231,13 @@ public class BackgroundExecutor {
|
||||
// force termination
|
||||
task.cancel();
|
||||
executor.shutdown();
|
||||
if (executor.awaitTermination(5, TimeUnit.SECONDS)) {
|
||||
if (executor.awaitTermination(2, TimeUnit.SECONDS)) {
|
||||
LOG.debug("Task cancel complete");
|
||||
return;
|
||||
}
|
||||
LOG.debug("Forcing tasks cancel");
|
||||
executor.shutdownNow();
|
||||
boolean complete = executor.awaitTermination(30, TimeUnit.SECONDS);
|
||||
boolean complete = executor.awaitTermination(5, TimeUnit.SECONDS);
|
||||
LOG.debug("Forced task cancel status: {}",
|
||||
complete ? "success" : "fail, still active: " + executor.getActiveCount());
|
||||
}
|
||||
|
@ -356,6 +356,10 @@ public abstract class AbstractCodeArea extends RSyntaxTextArea {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isDisposed() {
|
||||
return node == null;
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
// code area reference can still be used somewhere in UI objects,
|
||||
// reset node reference to allow to GC jadx objects tree
|
||||
@ -363,6 +367,10 @@ public abstract class AbstractCodeArea extends RSyntaxTextArea {
|
||||
contentPanel = null;
|
||||
|
||||
// also clear internals
|
||||
setIgnoreRepaint(true);
|
||||
setText("");
|
||||
setEnabled(false);
|
||||
setSyntaxEditingStyle(SYNTAX_STYLE_NONE);
|
||||
setLinkGenerator(null);
|
||||
for (MouseListener mouseListener : getMouseListeners()) {
|
||||
removeMouseListener(mouseListener);
|
||||
|
@ -165,10 +165,15 @@ public final class ClassCodeContentPanel extends AbstractCodeContentPanel implem
|
||||
} catch (Exception e) {
|
||||
LOG.debug("Failed to restore view position: {}", viewState.getViewPoint(), e);
|
||||
}
|
||||
int caretPos = viewState.getCaretPos();
|
||||
try {
|
||||
activePanel.getCodeArea().setCaretPosition(viewState.getCaretPos());
|
||||
AbstractCodeArea codeArea = activePanel.getCodeArea();
|
||||
int codeLen = codeArea.getDocument().getLength();
|
||||
if (caretPos >= 0 && caretPos < codeLen) {
|
||||
codeArea.setCaretPosition(caretPos);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.debug("Failed to restore caret position: {}", viewState.getCaretPos(), e);
|
||||
LOG.debug("Failed to restore caret position: {}", caretPos, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -85,6 +85,10 @@ public final class CodeArea extends AbstractCodeArea {
|
||||
@Override
|
||||
public ICodeInfo getCodeInfo() {
|
||||
if (cachedCodeInfo == null) {
|
||||
if (isDisposed()) {
|
||||
LOG.debug("CodeArea used after dispose!");
|
||||
return ICodeInfo.EMPTY;
|
||||
}
|
||||
cachedCodeInfo = Objects.requireNonNull(node.getCodeInfo());
|
||||
}
|
||||
return cachedCodeInfo;
|
||||
|
@ -29,9 +29,12 @@ public final class JadxTokenMaker extends JavaTokenMaker {
|
||||
|
||||
@Override
|
||||
public Token getTokenList(Segment text, int initialTokenType, int startOffset) {
|
||||
if (codeArea.isDisposed()) {
|
||||
return new TokenImpl();
|
||||
}
|
||||
try {
|
||||
Token tokens = super.getTokenList(text, initialTokenType, startOffset);
|
||||
if (tokens.getType() != TokenTypes.NULL) {
|
||||
if (tokens != null && tokens.getType() != TokenTypes.NULL) {
|
||||
processTokens(tokens);
|
||||
}
|
||||
return tokens;
|
||||
|
Loading…
Reference in New Issue
Block a user