Skip to content

Commit

Permalink
fix(gui): ignore errors on code area dispose (#1545)
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Jun 28, 2022
1 parent 0721a6b commit d972d9e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
46 changes: 25 additions & 21 deletions jadx-gui/src/main/java/jadx/gui/ui/codearea/AbstractCodeArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -367,29 +367,33 @@ public void dispose() {
contentPanel = null;

// also clear internals
setIgnoreRepaint(true);
setText("");
setEnabled(false);
setSyntaxEditingStyle(SYNTAX_STYLE_NONE);
setLinkGenerator(null);
for (MouseListener mouseListener : getMouseListeners()) {
removeMouseListener(mouseListener);
}
for (MouseMotionListener mouseMotionListener : getMouseMotionListeners()) {
removeMouseMotionListener(mouseMotionListener);
}
JPopupMenu popupMenu = getPopupMenu();
for (PopupMenuListener popupMenuListener : popupMenu.getPopupMenuListeners()) {
popupMenu.removePopupMenuListener(popupMenuListener);
}
for (Component component : popupMenu.getComponents()) {
if (component instanceof JMenuItem) {
Action action = ((JMenuItem) component).getAction();
if (action instanceof JNodeAction) {
((JNodeAction) action).dispose();
try {
setIgnoreRepaint(true);
setText("");
setEnabled(false);
setSyntaxEditingStyle(SYNTAX_STYLE_NONE);
setLinkGenerator(null);
for (MouseListener mouseListener : getMouseListeners()) {
removeMouseListener(mouseListener);
}
for (MouseMotionListener mouseMotionListener : getMouseMotionListeners()) {
removeMouseMotionListener(mouseMotionListener);
}
JPopupMenu popupMenu = getPopupMenu();
for (PopupMenuListener popupMenuListener : popupMenu.getPopupMenuListeners()) {
popupMenu.removePopupMenuListener(popupMenuListener);
}
for (Component component : popupMenu.getComponents()) {
if (component instanceof JMenuItem) {
Action action = ((JMenuItem) component).getAction();
if (action instanceof JNodeAction) {
((JNodeAction) action).dispose();
}
}
}
popupMenu.removeAll();
} catch (Throwable e) {
LOG.debug("Error on code area dispose", e);
}
popupMenu.removeAll();
}
}
4 changes: 2 additions & 2 deletions jadx-gui/src/main/java/jadx/gui/ui/codearea/SmaliArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ public void scrollToDebugPos(int pos) {

@Override
public Font getFont() {
if (model == null) {
if (model == null || isDisposed()) {
return super.getFont();
}
return model.getFont();
}

@Override
public Font getFontForTokenType(int type) {
return model.getFont();
return getFont();
}

private boolean shouldUseSmaliPrinterV2() {
Expand Down

0 comments on commit d972d9e

Please sign in to comment.