diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanelRenderModeImage.java b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanelRenderModeImage.java index 73a8bd1392d..631f453327f 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/CardPanelRenderModeImage.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/CardPanelRenderModeImage.java @@ -563,11 +563,23 @@ public class CardPanelRenderModeImage extends CardPanel { public void doLayout() { super.doLayout(); - int cardWidth = getCardLocation().getCardWidth(); // must use current panel sizes to scale real image - int cardHeight = getCardLocation().getCardHeight(); + int cardWidth; + int cardHeight; int cardXOffset = 0; int cardYOffset = 0; + // workaround to fix a rare NPE error with image loading + // reason: panel runs image load in another thread and that thread can be completed before top panel init, see updateArtImage + if (getTopPanelRef() == null) { + //noinspection deprecation - it's ok for workaround + cardWidth = this.getWidth(); + //noinspection deprecation - it's ok for workaround + cardHeight = this.getHeight(); + } else { + cardWidth = getCardLocation().getCardWidth(); // must use real card sizes to scale real image + cardHeight = getCardLocation().getCardHeight(); + } + CardSizes sizes = new CardSizes(getInsets(), cardXOffset, cardYOffset, cardWidth, cardHeight); // origin card without selection diff --git a/Mage.Client/src/main/java/org/mage/card/arcane/Util.java b/Mage.Client/src/main/java/org/mage/card/arcane/Util.java index cbc3af717bd..ee057202355 100644 --- a/Mage.Client/src/main/java/org/mage/card/arcane/Util.java +++ b/Mage.Client/src/main/java/org/mage/card/arcane/Util.java @@ -22,7 +22,7 @@ public final class Util { public static final boolean isMac = System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("mac"); public static final boolean isWindows = !System.getProperty("os.name").toLowerCase(Locale.ENGLISH).contains("windows"); - public static final ThreadPoolExecutor threadPool; + public static final ThreadPoolExecutor threadPool; // uses for card images loading static private int threadCount; static {