Skip to content

Commit

Permalink
fix(gui): try to handle exception in RSTA.getPreferredSize() (#1712)
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Oct 29, 2022
1 parent 4db50fb commit b28f8ba
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions jadx-gui/src/main/java/jadx/gui/ui/codearea/AbstractCodeArea.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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;
Expand Down Expand Up @@ -396,4 +397,24 @@ public void dispose() {
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;
}
}
}

0 comments on commit b28f8ba

Please sign in to comment.