fix(gui): ignore errors on code area dispose (#1545)

This commit is contained in:
Skylot
2022-06-28 16:20:31 +01:00
parent 0721a6b050
commit d972d9ec74
2 changed files with 27 additions and 23 deletions
@@ -367,29 +367,33 @@ 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);
}
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();
}
}
@@ -136,7 +136,7 @@ public final class SmaliArea extends AbstractCodeArea {
@Override
public Font getFont() {
if (model == null) {
if (model == null || isDisposed()) {
return super.getFont();
}
return model.getFont();
@@ -144,7 +144,7 @@ public final class SmaliArea extends AbstractCodeArea {
@Override
public Font getFontForTokenType(int type) {
return model.getFont();
return getFont();
}
private boolean shouldUseSmaliPrinterV2() {