Skip to content

Commit

Permalink
fix NPE when rendering "demo/lists.html" in BrowserStartup
Browse files Browse the repository at this point in the history
  • Loading branch information
asolntsev committed Oct 26, 2024
1 parent ae00427 commit 296b2f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public static ImageResource loadImageResourceFromUri(final String uri) {

try (InputStream is = IOUtil.getInputStream(uri)) {
try {
if (is == null) {
return createImageResource(uri, null);
}
BufferedImage img = ImageIO.read(is);
if (img == null) {
throw new IOException("ImageIO.read() returned null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,16 @@ protected void doRender(RenderingContext c, Layer root) {
AffineTransform current = g.getTransform();

PaintingInfo pI = root.getMaster().getPaintingInfo();
Dimension layoutSize = pI.getOuterMarginCorner();
if (pI != null) {
Dimension layoutSize = pI.getOuterMarginCorner();

calculateScaleAccordingToPolicy(layoutSize);
calculateScaleAccordingToPolicy(layoutSize);

if (lastLayoutSize == null) {
lastLayoutSize = layoutSize;
setPreferredSize(new Dimension((int) (lastLayoutSize.width * scale), (int) (lastLayoutSize.height * scale)));
revalidate();
if (lastLayoutSize == null) {
lastLayoutSize = layoutSize;
setPreferredSize(new Dimension((int) (lastLayoutSize.width * scale), (int) (lastLayoutSize.height * scale)));
revalidate();
}
}

g.transform(AffineTransform.getScaleInstance(scale, scale));
Expand Down

0 comments on commit 296b2f2

Please sign in to comment.