未验证 提交 b28f8ba8 编写于 作者: S Skylot

fix(gui): try to handle exception in `RSTA.getPreferredSize()` (#1712)

上级 4db50fb7
......@@ -2,6 +2,7 @@ package jadx.gui.ui.codearea;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
......@@ -396,4 +397,24 @@ public abstract class AbstractCodeArea extends RSyntaxTextArea {
LOG.debug("Error on code area dispose", e);
}
}
@Override
public Dimension getPreferredSize() {
try {
return super.getPreferredSize();
} catch (Exception e) {
LOG.warn("Failed to calculate preferred size for code area", e);
// copied from javax.swing.JTextArea.getPreferredSize (super call above)
// as a fallback for returned null size
Dimension d = new Dimension(400, 400);
Insets insets = getInsets();
if (getColumns() != 0) {
d.width = Math.max(d.width, getColumns() * getColumnWidth() + insets.left + insets.right);
}
if (getRows() != 0) {
d.height = Math.max(d.height, getRows() * getRowHeight() + insets.top + insets.bottom);
}
return d;
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册